Welcome Guest, Not a member yet? Register   Sign In
too slow, ~12 sec for load
#11

[eluser]davidino86[/eluser]
second part


Code:
function bestAds()
    {
        $data['query'] = $this->annunci->get_random_ADV();
        $this->template->parse_view('content', 'panels/best_ads_view', $data);
    }

    function latestNews()
    {
        $data['query_news'] = $this->news_model->get_latest_news(5);

        $i = 0;
        foreach ($data['query_news'] as $row_news)
        {
            $data['image_news'][$i] = $this->image_model->getThumb(mssql_guid_string($row_news->news_id));
            ++$i;
        }

        $this->template->parse_view('content', 'panels/latest_news_view', $data);
    }

    function loginThick()
    {
        $data['fal'] = $this->fal_front->login();
        $this->load->view('panels/loginThick_view', data);
    }
    
    function login_small()
    {
        $data['fal'] = $this->fal_front->login();
        $this->template->parse_view('nav_right', 'inc/login_form', $data);
    }

    function all_products_by_category()
    {
        $result = $this->categories_model->getCategoriesCompanies();
        $data['query'] = $result->result();
        $this->template->parse_view('sidebar_left', 'inc/sidebar_prodotti', $data);

    }

    function vetrina(){

                $data['query_vetrina'] = $this->supplier_model->get_discouted_products();

                 if (!empty($data['query_vetrina'])){
                    $i=0;
                   foreach($data['query_vetrina'] as $value)
                    {
                       //echo mssql_guid_string($value->company_ID).'<br>';
                       $data['media'][$i] = $this->image_model->get_images_reference(mssql_guid_string($value->supplier_product_ID));
                       //var_dump ($result['$i']);
                        ++$i;
                    }
                 }

                $this->template->parse_view('sidebar_right', 'inc/vetrina_view', $data);
    }

    
    function all_shop_companies()
    {
        $welcome_shop = $this->db_session->userdata('welcome_shop');
        
        if(isset($welcome_shop) && $welcome_shop != ''){
        
        $company_data = $this->companies_model->get_company($welcome_shop);
    

        $data = array(
                    'company_id' => mssql_guid_string($company_data->company_ID),    
                    'nome' => $company_data->companyName,
                    'logo' => $this->image_model->getLogo( mssql_guid_string($company_data->company_ID))
                );


          
        }else{          
            $data['query'] = $this->companies_model->get_ecommerce_companies();
        }
        $this->template->parse_view('sidebar_left', 'inc/sidebar_prodotti_shop', $data);

    }

    function menu()
    {
        $data['companies'] = $this->companies_model->get_public_companies();
        $data['companies_ecommerce'] = $this->companies_model->get_ecommerce_companies();

        $i=0;
        foreach ($data['companies'] as $row)
        {

            $data['name_cat'][$i] = $this->categories_model->get_name_from_id(mssql_guid_string($row->category_ID));
            $i++;
        }

        $this->template->parse_view('menu', 'inc/menu_view', $data);
    }

    function random_products_header()
    {
        $data['text'] = $this->companies_model->random_company_products();
    

        $i=0;

      
        if (!empty($data['text']))
        {

            foreach($data['text'] as $value)
            {              
                $data['text_product'][$i] = $this->companies_model->get_product_by_company(mssql_guid_string($value->company_ID));
                $data['logo'][$i] = $this->image_model->getLogo(mssql_guid_string($value->company_ID));
              

/* print_r($data['text_product'][$i]);
              $j = 0;
                foreach ($data['text_product'][$i] as $row)
                {
                    $data['product_id'][$j] = mssql_guid_string($row->company_product_ID);

                    ++$j;
                }
                
                $data['media'][$i] = $this->image_model->get_images_reference(mssql_guid_string($data['product_id'][$i]));*/
                $j = 0;
                foreach ($data['text_product'][$i] as $value_image)
                    {
                        $data['media'][$i][$j] = $this->image_model->get_images_reference(mssql_guid_string($value_image->company_product_ID));

                       /* echo mssql_guid_string($value_image->company_product_ID).'<br /><br />';
                        print_r($data['media'][$j]);
                        echo '<br /><br />';
                        */
                        ++$j;
                    }
                
                ++$i;
            }



          
            
            

        }


        $this->template->parse_view('header', 'inc/random_products_header_view', $data);
        
        

    }

    function _sendEmail($email, $subject, $message)
    {

        $this->load->library('email');
        $this->email->clear();

        //Configuring SMTP Host
        $config['smtp_host'] = 'localhost';
        $config['mailtype'] = 'html';

        $this->email->initialize($config);

        $this->email->from($this->config->item('pbb_adminEmailAddress'));
        $this->email->to($email);
        $this->email->subject($subject);
        $this->email->message($message);
        $this->email->send();
    }


}

?&gt;
#12

[eluser]davidino86[/eluser]
i was thinking about the autoload configuration, but i don't know.

i've insert the cache control to 5 minutes and it solve temporarily the problem
#13

[eluser]mddd[/eluser]
With this kind of slow loads, I think the problem must be looked for in the database connection. There is no way the execution of the scripts themselves can be that slow (unless you write REALLY bad code).

It could be that you are doing some bad queries that take a long time, or it can be that the server is almost overloaded so that you have to wait a long time before the database returns anything useful.

I don't see any profiler info, but I think you should focus on the database queries in the profiler and see which take a long time. Then check if there is an optimization problem in those queries, or that the database is just too slow.. which can happen in shared hosting packages, especially on budget-providers.
#14

[eluser]davidino86[/eluser]
what do you mean for looking for in the database connection. Now i put the p_connect to false because everytime you go to another page the php opens a new connection and stay opened for the rest of navigation.

the heaviest query takes 0.0291 sec and it's an "update" query.

anyway i see the profiler now.

what do you think about the class of the home controller?
#15

[eluser]mddd[/eluser]
I meant checking the queries like you did. I just can't imagine which piece of code could take so long. The controller is really only loading pieces of information and displaying them. Nothing special there that should take that long.

You could try and find out more details by putting in some benchmark points. For instance at the beginning and end of each function. To find out which parts take the longest. Check out the profiler/benchmark classes to find examples of this.
#16

[eluser]Xperia[/eluser]
Just had a quick look, you have a lot of DB queries that do add upp, like:
Code:
0.0006       SELECT Impressions
FROM AdvertisingBanner
WHERE ID_Banner = 'AC72C24A-045E-4638-9387-5990546DE55F'
0.0695       UPDATE AdvertisingBanner SET Impressions = 1910 WHERE ID_Banner = 'AC72C24A-045E-4638-9387-5990546DE55F'

You should just do it with just one DB statement, like:
Code:
UPDATE AdvertisingBanner SET Impressions = Impressions+1 WHERE ID_Banner = 'AC72C24A-045E-4638-9387-5990546DE55F'
#17

[eluser]davidino86[/eluser]
i'll do it and i'll let you know
#18

[eluser]davidino86[/eluser]
[quote author="Xperia" date="1280255340"]Just had a quick look, you have a lot of DB queries that do add upp, like:
Code:
0.0006       SELECT Impressions
FROM AdvertisingBanner
WHERE ID_Banner = 'AC72C24A-045E-4638-9387-5990546DE55F'
0.0695       UPDATE AdvertisingBanner SET Impressions = 1910 WHERE ID_Banner = 'AC72C24A-045E-4638-9387-5990546DE55F'

You should just do it with just one DB statement, like:
Code:
UPDATE AdvertisingBanner SET Impressions = Impressions+1 WHERE ID_Banner = 'AC72C24A-045E-4638-9387-5990546DE55F'
[/quote]

the second query i apart from the first and it 's like you wrote
#19

[eluser]John_Betong[/eluser]
Your site eventually displays in Opera but will not load with Firefox and Google Chrome.

I looked at the source and discovered that you load thirteen style sheets and nineteen javascript files in the header section.

Try moving all the javascript file to immediately before your &lt;/body&gt;> and it should make the page load quite a bit faster.
&nbsp;
&nbsp;
&nbsp;
#20

[eluser]Jelmer[/eluser]
I'm kinda guessing there's a loop somewhere within your code that causes this. I had that a while back after changing something small and I found the cause by adding exit('something') and moving that statement down from the top until the pageload started to slow down instead of immediately showing the text.

It might indeed also be caused by a slow loading stylesheet, but as I get an error saying script execution took too long it's probably the page itself that is the problem.




Theme © iAndrew 2016 - Forum software by © MyBB