RE: [PHP] Most efficient way of fetching 1,000 records from MySQL ?
| From: | Graham Cossey | Date: | Mon, 25 Oct 2004 11:40:37 +0000 |
| Subject: | RE: [PHP] Most efficient way of fetching 1,000 records from MySQL ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200234@lists.php.net to get a copy of this message | ||
I would certainly agree with Marek.
I recently changed a query from using 20 or so 'OR' conditions to use the
'IN' statement and it drastically improved the performance of the query.
Graham
> -----Original Message-----
> From: Marek Kilimajer [mailto:lists@kilimajer.net]
> Sent: 25 October 2004 11:37
> To: Ian Firla
> Cc: Steve McGill; php-general@lists.php.net
> Subject: Re: [PHP] Most efficient way of fetching 1,000 records from
> MySQL ?
>
>
> Ian Firla wrote:
> > I think you'll find that your first approach is not only more correct,
> > it's the only manageable one.
>
> No, it will be very slow. The biggest overhead is in transfering data to
> and from sql server. It's always better to get the results in one
> sql query.
>
> Use this aproach:
>
> $users =
> sql('select * from users where userID IN ('. implode(', ',$users)
> .')');
>
> >
[snip]