Subject | Is this the most effective way of counting unique rows? |
---|---|
Author | un_spoken |
Post date | 2013-01-16T09:08:44Z |
Hi guys.
Here is an example:
CREATE TABLE TEST
(
ID1 INTEGER,
ID2 INTEGER,
ID3 INTEGER
)
INSERT INTO TEST VALUES(1,1,1);
INSERT INTO TEST VALUES(1,1,1);
INSERT INTO TEST VALUES(1,2,1);
INSERT INTO TEST VALUES(1,1,3);
SELECT COUNT(*) FROM
(
SELECT
DISTINCT ID1, ID2, ID3
FROM
TEST
)
Is above query the fastest way of counting unique rows?
I was browsing the Internet but could't find the definitive answer.
Thanks for your time.
Here is an example:
CREATE TABLE TEST
(
ID1 INTEGER,
ID2 INTEGER,
ID3 INTEGER
)
INSERT INTO TEST VALUES(1,1,1);
INSERT INTO TEST VALUES(1,1,1);
INSERT INTO TEST VALUES(1,2,1);
INSERT INTO TEST VALUES(1,1,3);
SELECT COUNT(*) FROM
(
SELECT
DISTINCT ID1, ID2, ID3
FROM
TEST
)
Is above query the fastest way of counting unique rows?
I was browsing the Internet but could't find the definitive answer.
Thanks for your time.