Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Speeding up viewers

 

 


pothompson
User

Mar 23, 2009, 9:44 AM

Post #1 of 3 (759 views)
Shortcut
Speeding up viewers Can't Post

I have created a section editor and imported approximately 10,000 records into the MySQL table.

I'm trying to display a number of records from the table using the standard view code (list($records,$meta)=getRecords....) and am narrowing the search down using the where attribute. The where that I'm using is only relates to one column. I was wondering if there was any way of creating an index or similar to speed up this search as currently it seems to take a while.

An example of the full code is

$product_where='CATEGORY="10" AND CATEGORY="34" AND CATEGORY="78"';
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => $product_where,
));

Thanks - Paul.




Dave
Staff / Moderator


Mar 23, 2009, 12:13 PM

Post #2 of 3 (753 views)
Shortcut
Re: [pothompson] Speeding up viewers [In reply to] Can't Post

Hi Paul,

It shouldn't take very long at all with 10,000 records. But it does depend on the web host. How many seconds is it?

You can add the following options to speed things up:

'loadUploads' => false, // won't load uploads
'loadCreatedBy' => false, // won't load values for record author user

And there is no automated way to create an index but you could do that with phpMyAdmin or MySQL Query Browser or something like that.

Also, I'm not sure how this query would return any results because a category couldn't be 10 and 34 and 78 at the same time. Did you mean OR?

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com
 


pothompson
User

Mar 23, 2009, 12:30 PM

Post #3 of 3 (751 views)
Shortcut
Re: [Dave] Speeding up viewers [In reply to] Can't Post

I did mean OR, I read and re-read that code before I posted it to the whole world to make sure I hadn't made any mistakes!

Maybe it's not the MySQL taking a long time then, it's just the whole page takes a while to load and I'm trying to replicate an existing (non database-driven) site so I can compare the two and my version is a lot slower.

I'll have a look at a few other areas to see if I can find bottleneck.

Thanks, Paul.