ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Database Overloading

July 17, 2010 1:55am

Subscribe [3]
  • #1 / Jul 17, 2010 1:55am

    MINDSCREEN

    218 posts

    Hi

    We faced a serious problem of Database overloading for a small change. Our site http://www.mercatornet.com is fully articles based, where some articles are contributed by multiple authors. For such, we supposed to include a new field for 2nd author and show his/her name in the frontpage also. You can see the site, open any articles, click on the author name, it will show all the articles posted by that author for that blog. We tried to do same thing for 2nd author also. If any articles has multiple authors, both authors name will appear as {author} and {author_2nd}.

    But, using this concept, we face a huge overloading on our database and the site became down, we hoped it may be for hardware failure, we are using a VPS for our site, but increasing the hardwares it not restored until we remove all the work related for 2nd author issue. As soon we removed those works, the server became stable. We are really not expected that adding a single field and simple quires will do such mess. If you are interested I can forward you the communication with the Sever Support Team with us.

    Following is the steps we did for 2nd author issue:-

    Field Name :- author_2nd
    Field Label :- Another Author
    Filed Type :- Textfield
    Field ID :- field_id_120

    Template :- articles/view

    <?
        $track = 'track_views="one"';
        $url = $_SERVER['REQUEST_URI'];
        if(preg_match(":\?view$:", $url)) {
            $track = "";
        }
    ?>
    {exp:weblog:entries weblog="articles" status="not closed" <? echo $track; ?> limit="1" rdf="off"}
    {if no_results}
    {embed="site/default_header"}
    {/if}
    {embed="articles/header2" description="{summary}"}
        <div class="article">
            <div class="authordate"><a href="http://{title_permalink=sections/author_page}class=navLink1">{author_name}</a>{if author_2nd} and <a href="http://{title_permalink=sections/author_page2}class=navLink1">{author_2nd}</a>{/if} | {entry_date format="%l, %j %F %Y"}<br>tags : {exp:tag:tags entry_id="{entry_id}" backspace="2"}<a href="http://{path=%27articles/tag%27}{websafe_tag}" title="{tag}">{tag}</a>, {/exp:tag:tags}</div>
            <h1>{title}</h1>
            <h2>{summary}</h2>
    <p><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.mercatornet.com/articles/view/{url_title}/&layout=standard&show_faces=true&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:30px"></iframe><br><br><br />
            </div>

    Template :- sections/author_page2

    {exp:weblog:entries weblog="articles|reviews|backgrounders" rdf="off" status="not closed|editing" limit="1" disable="categories|member_data|pagination|trackbacks"}
        <h1>{author_2nd}</h1>
        <? $author = str_replace("'", "\'", "{author_2nd}"); ?>
                    {embed=sections/more_by_author_query3 author="<? echo $author; ?>"}
    {/exp:weblog:entries}

    Template :- sections/more_by_author_query3

    {exp:query limit="12" paginate="bottom" sql="SELECT w.blog_name, t.title, t.url_title, t.entry_date, t.entry_id, d.field_id_12, d.field_id_85, d.field_id_120
    FROM exp_weblogs AS w, exp_weblog_titles AS t, exp_weblog_data AS d
    WHERE w.weblog_id = t.weblog_id
    AND t.entry_id = d.entry_id
    AND t.entry_date < UNIX_TIMESTAMP( )
    AND d.field_id_120 = '{embed:author}'
    OR d.field_id_12 = '{embed:author}'
    AND (t.status != 'closed' AND t.status != 'editing')
    AND (
    w.weblog_id =4
    OR w.weblog_id =5
    OR w.weblog_id =7
    )
    ORDER BY t.entry_date DESC"}
    <ul>
    <hr>
    <a href="http://{path={blog_name}/view/{url_title}}" class="features1"><h3>{title}</h3><p></a></p><h5>{if field_id_120}{field_id_120} | {/if}{entry_date format="%j %M %Y"}</h5>
    <h5>{field_id_85}</h5><p><br><br />
    </ul><br />
    {paginate}Page {current_page} of {total_pages} : {pagination_links}{/paginate}<br />
    {/exp:query}

    Can You Pls, check the issue and inform us where was the problem? We did the same work for main author and its working well for years, but we faced trouble for 2nd author issue. We need to use this concept for our website. Looking forward to hear from you soon with positive response. If you need anything more, Pls, inform us.

  • #2 / Jul 17, 2010 3:06pm

    Greg Salt

    3988 posts

    Hi MINDSCREEN,

    Did you switch on Template Debugging and SQL Queries at Admin > System Preferences > Output and Debugging Preferences to see where the extra load is concentrated?

    Cheers

    Greg

  • #3 / Jul 19, 2010 11:11am

    MINDSCREEN

    218 posts

    Hi Greg,

    No…will I do such? Is there any problem in the coding or queries?

  • #4 / Jul 19, 2010 3:20pm

    Ingmar

    29245 posts

    Is there any problem in the coding or queries?

    That’s precisely one of the things Template Debugging is meant to help us determine. Can you copy & paste the debugging output into a text file and attach it here?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases