Re: [PERFORM] which one is faster

2010-10-26 Thread Mladen Gogala
On 10/26/2010 6:56 AM, AI Rumman wrote: Which one is faster? select count(*) from talble or select count(id) from table where id is the primary key. PostgreSQL doesn't utilize the access methods known as "FULL INDEX SCAN" and "FAST FULL INDEX SCAN", so the optimizer will generate the sequential

Re: [PERFORM] which one is faster

2010-10-26 Thread Szymon Guz
2010/10/26 Grzegorz Jaśkiewicz > 2010/10/26 Szymon Guz : > > > > Well, strange. Why is that slower? > > To answer that fully, you would need to see the implementation. > suffice to say, > > count(a) does: > > if (a <> NULL) > { > count++; > } > > and count(*) does: > > count++; > > > Yup, I was

Re: [PERFORM] which one is faster

2010-10-26 Thread Grzegorz Jaśkiewicz
2010/10/26 Szymon Guz : > > Well, strange. Why is that slower? To answer that fully, you would need to see the implementation. suffice to say, count(a) does: if (a <> NULL) { count++; } and count(*) does: count++; -- GJ -- Sent via pgsql-performance mailing list (pgsql-performance@po

Re: [PERFORM] which one is faster

2010-10-26 Thread Szymon Guz
2010/10/26 Grzegorz Jaśkiewicz > implementation wise, count(*) is faster. Very easy to test: > > SELECT COUNT(*) FROM generate_series(1,100) a, generate_series(1,1000) b; > > SELECT COUNT(a) FROM generate_series(1,100) a, generate_series(1,1000) b; > > > ;] > Well, strange. Why is that slower?

Re: [PERFORM] which one is faster

2010-10-26 Thread Grzegorz Jaśkiewicz
implementation wise, count(*) is faster. Very easy to test: SELECT COUNT(*) FROM generate_series(1,100) a, generate_series(1,1000) b; SELECT COUNT(a) FROM generate_series(1,100) a, generate_series(1,1000) b; ;] -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To m

Re: [PERFORM] which one is faster

2010-10-26 Thread Szymon Guz
2010/10/26 Marcin Mirosław > W dniu 26.10.2010 12:59, Szymon Guz pisze: > > both queries are the same. > > IMHO they aren't the same, but they returns the same value in this case. > I mean count(field) doesn't count NULL values, count(*) does it. > I'm writing this only for note:) > Regards > > Y

Re: [PERFORM] which one is faster

2010-10-26 Thread Marcin Mirosław
W dniu 26.10.2010 12:59, Szymon Guz pisze: > both queries are the same. IMHO they aren't the same, but they returns the same value in this case. I mean count(field) doesn't count NULL values, count(*) does it. I'm writing this only for note:) Regards -- Sent via pgsql-performance mailing list (p

Re: [PERFORM] which one is faster

2010-10-26 Thread Szymon Guz
On 26 October 2010 12:56, AI Rumman wrote: > Which one is faster? > select count(*) from talble > or > select count(id) from table > where id is the primary key. > Check the query plan, both queries are the same. regards Szymon

[PERFORM] which one is faster

2010-10-26 Thread AI Rumman
Which one is faster? select count(*) from talble or select count(id) from table where id is the primary key.

[PERFORM] Which one is faster: one way reading ="single pass reading"

2005-03-20 Thread Rosny
Hi, Which one is faster: one way reading ="single pass reading" Assumption : a. Need to have 3 millions records b. Need to have call 10 or 20 records repeatly (so for database it will be 10 times connection, each connection with one record. or can be fancy 1 connection call return 10 sets of