Re: [PERFORM] which one is faster
On 26 October 2010 12:56, AI Rumman rumman...@gmail.com 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
Re: [PERFORM] which one is faster
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 (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance
Re: [PERFORM] which one is faster
2010/10/26 Marcin Mirosław mar...@mejor.pl 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 Yup, indeed. I omitted that note, as it was written that the field is primary key :). regards Szymon
Re: [PERFORM] which one is faster
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 make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance
Re: [PERFORM] which one is faster
2010/10/26 Grzegorz Jaśkiewicz gryz...@gmail.com 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 Grzegorz Jaśkiewicz gryz...@gmail.com 2010/10/26 Szymon Guz mabew...@gmail.com: 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 afraid of that, even if there is not null on the column... but I think usually nobody notices the difference with count. regards Szymon
Re: [PERFORM] which one is faster
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 scan in both cases. In other words, PostgreSQL will read the entire table when counting, no matter what. -- Mladen Gogala Sr. Oracle DBA 1500 Broadway New York, NY 10036 (212) 329-5251 www.vmsinfo.com -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance
[PERFORM] Which one is faster: one way reading =single pass reading
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 records) 1. Reading from Flat file Assume already give file name and just need to read the file (since it is flat file, each record represent a filename, with multiple directory category) 2. Reading from XML file Assume schema already given just need to read the file (since it is xml file, each record represent an xml filename, with multiple directory category) 3. Reading from Postgresql Assume primary key has been done with indexing just need to search the number and grap the text content (assume 3 millions of records, search the number, read the content file) trying to recreate WebDBReader (from nutch) using C# http://nutch.sourceforge.net/docs/api/net/nutch/db/WebDBReader.html Thank you in advances, Rosny ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq