Generated count queries with CriteriaBuilder [message #1713192] |
Mon, 02 November 2015 08:55 |
Maciej Lizewski Messages: 2 Registered: October 2015 |
Junior Member |
|
|
Hi,
I am using eclipselink with spring data and postgresql. I noticed that when getting paged results generated count queries looks like this:
SELECT COUNT(id) FROM table WHERE [condition]
where "id" is primary key of "table" and [condition] is generated according to provided specification (and criteria builder). I traced whole process and it seems it is up to eclipselink to provide count query in this particular form.
Now - for very large tables COUNT(id) is (as in my case explain shows) about 10 times slower than COUNT(*), because COUNT(id) reaches for every row "id" value and checks if it is not null, while COUNT(*) counts every row matching criteria. This makes it impossible to use indexes.
Is it possible to change behavior of eclipselink so that it generates COUNT(*) instead of COUNT(id)? *any* way?
thanks in advance for any feedback.
|
|
|
Powered by
FUDForum. Page generated in 0.03700 seconds