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
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
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
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?
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
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
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
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
Which one is faster?
select count(*) from talble
or
select count(id) from table
where id is the primary key.
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
10 matches
Mail list logo