Re: [PHP] Fastest way to get table records' number

2008-03-20 Thread Philip Thompson
On Mar 19, 2008, at 11:55 PM, Shelley wrote: Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O mysql

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Daniel Brown
On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote: Hi all, What do you think is the FASTEST sql to get the total number of a table with millions of records? That question would be better on the PHP-DB list, so for archive's sake, I'm CC'ing that list. $sql = SELECT

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Andrew Ballard
On Tue, Mar 18, 2008 at 11:47 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote: Hi all, What do you think is the FASTEST sql to get the total number of a table with millions of records? when you say 'total number' do you mean

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Stut
Shelley wrote: What do you think is the FASTEST sql to get the total number of a table with millions of records? Generally speaking 'select count(1) from table' is the quickest way, but it really depends on the database and storage engine you're using. Your best bet is to look at the

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Nathan Nobbe
On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O mysql select count(*) from table; +--+ | count(*) | +--+ |

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Mikey
Nathan Nobbe wrote: On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote: Hi all, What do you think is the FASTEST sql to get the total number of a table with millions of records? when you say 'total number' do you mean the total number of records? in that case assuming the

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread tedd
At 10:35 AM -0400 3/19/08, Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O mysql select count(*) from

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Andrew Ballard
On Wed, Mar 19, 2008 at 10:35 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Stut
On 19 Mar 2008, at 14:53, tedd wrote: At 10:35 AM -0400 3/19/08, Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Andrew Ballard
On Wed, Mar 19, 2008 at 10:53 AM, tedd [EMAIL PROTECTED] wrote: At 10:35 AM -0400 3/19/08, Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*).

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread jeffry s
On Wed, Mar 19, 2008 at 10:57 PM, Andrew Ballard [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 10:53 AM, tedd [EMAIL PROTECTED] wrote: At 10:35 AM -0400 3/19/08, Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Stut
jeffry s wrote: what about SELECT MAX(id) FROM table :) Won't give you the number of records, just the highest ID. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Fastest way to get table records' number

2008-03-19 Thread Edward Kay
At 10:35 AM -0400 3/19/08, Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread TG
: [PHP] Fastest way to get table records' number On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O mysql select count(*) from

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Andrew Ballard
On Wed, Mar 19, 2008 at 1:04 PM, TG [EMAIL PROTECTED] wrote: It seems that count(*) pulls all the data from the row then performs a count increment whereas count(did) only pulls the 'did' column. Again, I don't believe COUNT(*) pulls any data. If there is a row, it simply counts it. The row

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Daniel Brown
On Wed, Mar 19, 2008 at 1:19 PM, Andrew Ballard [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 1:04 PM, TG [EMAIL PROTECTED] wrote: It seems that count(*) pulls all the data from the row then performs a count increment whereas count(did) only pulls the 'did' column. Again, I

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread It Maq
Hi, did you try mysql_num_rows ? --- Andrew Ballard [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 1:04 PM, TG [EMAIL PROTECTED] wrote: It seems that count(*) pulls all the data from the row then performs a count increment whereas count(did) only pulls the 'did' column. Again,

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread David Giragosian
Doesn't the 1 in Select count(1) from table refer to the first column in the table, like order by 1 asc? David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Daniel Brown
On Wed, Mar 19, 2008 at 1:53 PM, David Giragosian [EMAIL PROTECTED] wrote: Doesn't the 1 in Select count(1) from table refer to the first column in the table, like order by 1 asc? No, it evaluates to Boolean TRUE. It's the same as the one (1) here: SELECT * FROM table WHERE 1; --

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread TG
-general@lists.php.net Date: Wed, 19 Mar 2008 10:38:16 -0700 (PDT) Subject: Re: [PHP] Fastest way to get table records' number Hi, did you try mysql_num_rows ? --- Andrew Ballard [EMAIL PROTECTED] wrote: On Wed, Mar 19, 2008 at 1:04 PM, TG [EMAIL PROTECTED] wrote: It seems that count

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Shelley
Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O mysql select count(*) from table; +--+ |

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Shelley
Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O mysql select count(*) from table; +--+ |

Re: [PHP] Fastest way to get table records' number

2008-03-19 Thread Shelley
Nathan Nobbe wrote: On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard [EMAIL PROTECTED] wrote: That works; I'm just wondering why you went with a count on an 'ID' column rather than COUNT(*). ouch, it looks like im horribly wrong :O mysql select count(*) from table; +--+ |

[PHP] Fastest way to get table records' number

2008-03-18 Thread Shelley
Hi all, What do you think is the FASTEST sql to get the total number of a table with millions of records? -- Regards, Shelley (http://phparch.cn) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Fastest way to get table records' number

2008-03-18 Thread Nathan Nobbe
On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote: Hi all, What do you think is the FASTEST sql to get the total number of a table with millions of records? when you say 'total number' do you mean the total number of records? in that case assuming the table has a field 'id'