500 records (articles) - SELECT ALL or USE WHERE
500 records (articles) - SELECT ALL or USE WHERE
am 05.08.2009 01:18:30 von Martin Zvarik
I need to do about 5 queries:
1) pick the top visited articles
2) pick the recent articles (limit 10)
3) pick the most commented articles
etc.
Now, I have 2 choices:
1) SELECT ALL records and use PHP for conditions
2) do 5 queries on MySQL
---
Imagine it has 500 long text articles.
Which of these 2 options is better for performance?
Thanks,
Martin
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: 500 records (articles) - SELECT ALL or USE WHERE
am 05.08.2009 01:30:02 von Patrick Price
--000325575b2231ab1d04705945ba
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Just shooting from the hip, I would say the faster method would be to creat=
e
the 5 different mysql queries. The amount of time taken up by retrieving
500 articles of either blob or text can add up to a significant amount of
time, whereas 5 queries that average 10 results per query would result in
~90% decrease in reading data from the database. Performing aggregate mysq=
l
functions for most commented and etc are generally very fast and can be don=
e
much more quickly than retrieving the whole article, passing to php, storin=
g
to memory and then manipulating the data.
Thanks
patrick
2009/8/4 Martin Zvar=EDk
> I need to do about 5 queries:
>
> 1) pick the top visited articles
> 2) pick the recent articles (limit 10)
> 3) pick the most commented articles
> etc.
>
> Now, I have 2 choices:
>
> 1) SELECT ALL records and use PHP for conditions
>
> 2) do 5 queries on MySQL
>
>
> ---
>
> Imagine it has 500 long text articles.
>
>
> Which of these 2 options is better for performance?
>
>
> Thanks,
>
> Martin
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--000325575b2231ab1d04705945ba--
Re: 500 records (articles) - SELECT ALL or USE WHERE
am 05.08.2009 01:41:53 von dmagick
Martin Zvarík wrote:
> I need to do about 5 queries:
>
> 1) pick the top visited articles
> 2) pick the recent articles (limit 10)
> 3) pick the most commented articles
> etc.
>
> Now, I have 2 choices:
>
> 1) SELECT ALL records and use PHP for conditions
>
> 2) do 5 queries on MySQL
>
>
> ---
>
> Imagine it has 500 long text articles.
For none of these situations you've mentioned do you need the text for
the articles. Don't select it if you don't need it.
> Which of these 2 options is better for performance?
Database. Not only for performance but for memory (imagine 100,000
articles).
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: 500 records (articles) - SELECT ALL or USE WHERE
am 05.08.2009 02:11:24 von Phpster
On Aug 4, 2009, at 7:18 PM, Martin ZvarÃk =
wrote:
> I need to do about 5 queries:
>
> 1) pick the top visited articles
> 2) pick the recent articles (limit 10)
> 3) pick the most commented articles
> etc.
>
> Now, I have 2 choices:
>
> 1) SELECT ALL records and use PHP for conditions
>
> 2) do 5 queries on MySQL
>
>
> ---
>
> Imagine it has 500 long text articles.
>
>
> Which of these 2 options is better for performance?
>
>
> Thanks,
>
> Martin
>
> -- =20
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Ensure that you can return the same data for each type of query and =20
then join then with a UNION statement and do it all in one query
Bastien
Sent from my iPod=
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php