1

I am creating an application with PHP ; Joomla 3 , Nooku and MySql Database , and I am interacting with the database to get datas from a table , i get over 64400 rows to 5 columns , but the problem is that the page gets over 6 minutes to load , especially JS functions :/

Help Please

7
  • 1
    Hi and welcome to JSE. Sorry but what exactly would you like us to do about this? You're loading just under 65k rows from a database and are experiencing slow loading times. This is expected for getting such a large amount of data, especially if you're on shared hosting. Maybe you should consider performing an Ajax call or caching the data
    – Lodder
    Apr 28 '15 at 9:12
  • I am not on shared hosting , the app is just on local , and what to you mean by caching the data?
    – user4147
    Apr 28 '15 at 9:14
  • 1
    Please read this: en.wikipedia.org/wiki/Cache_%28computing%29
    – Lodder
    Apr 28 '15 at 9:16
  • ok thank you i will
    – user4147
    Apr 28 '15 at 9:20
  • @Lodder i read all that but i dont see the relation with my problem , someone suggested to me to do a loop to take bloc by bloc means i have 60000 rows , take 10000 by 10000 ... etc
    – user4147
    Apr 28 '15 at 11:20
3

The reason your page is slow is because you are trying to load all or a lot of the data at once, or because your query isn't optimised correctly due to missing indexes. Hard to say without more info.

In case the query is optimised you need to ensure to paginate the loading of your data by LIMIT 'ing your query and resulting resultset.

Out of the box Nooku Framework does this for you and it prevents you from loading more then 100 rows at a time. You don't need to do anything extra to make this work. By using a correct controller/model/view setup pagination of data works out of the box in Nooku by adding limit and offset parameters to the URL query.

Nooku Framework uses offset out of the box, but also supports limitstart which is the Joomla equivalent.

A good example to get started with a correct setup Nooku is the getting started tutorial which runs you through creating a simple Todo extension for Joomla.

1

Selecting only the relevant rows is easy, provided the component has been properly integrated in the Joomla CMS. The first thing is to confirm you are requesting and storing the JPagination object from your view class:

public function display($tpl = null)
{
    $this->items        = $this->get('Items');
    $this->pagination   = $this->get('Pagination'); <-- IMPORTANT
    $this->state        = $this->get('State');

    NewsfeedsHelper::addSubmenu('newsfeeds');

    // Check for errors.
    if (count($errors = $this->get('Errors')))
    {
        JError::raiseError(500, implode("\n", $errors));
        return false;
    }

    $this->addToolbar();
    $this->sidebar = JHtmlSidebar::render();
    parent::display($tpl);
}

Here you are basically retrieving the pagination object to be used in the display. In the default.php file, you would add the following to your

<div class="btn-group pull-right hidden-phone">
    <label for="limit" class="element-invisible">
        <?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?>
    </label>
    <?php echo $this->pagination->getLimitBox(); ?>
</div>

Then in your table footer add the pagination navigation like so:

<tfoot>
    <tr>
        <td colspan="11">
            <?php echo $this->pagination->getListFooter(); ?>
        </td>
    </tr>
</tfoot>

By utilizing the framework properly, all the heavy lifting is already abstracted away from you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.