I'm using Aurora's Postgresql, The number of normal count queries does not match the number of rows when searching for records with an asterisk. What is the reason?
The system in question uses AWS Aurora and the 9.6.8 version of Postgresql as the engine. As shown below, the normal search results for Postgresql and the count results do not match.
normal searchSELECT * FROM samples WHERE date BETWEEN '2019-09-25 00:00:00' AND '2019-09-26 00:00:00';
As a result, 17613 records are returned.
count querySELECT COUNT(*) FROM samples WHERE date BETWEEN '2019-09-25 00:00:00' AND '2019-09-26 00:00:00';
17875 is returned as the count query.
This table has multiple primary keys and multiple columns that allow nulls.
Why is the number of results different between SELECT * and SELECT COUNT(*)?
By the way, if you specify a table name or primary key, it matches the number of records in normal search.
SELECT COUNT(sample_id) FROM samples WHERE date BETWEEN '2019-09-25 00:00:00' AND '2019-09-26 00:00:00';
or
SELECT COUNT(samples) FROM samples WHERE date BETWEEN '2019-09-25 00:00:00' AND '2019-09-26 00:00:00';
17613 is returned as the count query.
I'm going to cry because my job isn't working. Thank you.