Subject | 2 Queries which should return the same |
---|---|
Author | Ivar Abrahamsen <ivar@mindless.com> |
Post date | 2003-02-20T17:43:21Z |
I have these two queries.
And I was comparing the speeds ,
when I realised they were not returning the same value.
Both plans are natural.
select count(distinct ad.session) from accessdetails ad
where ad.recorded > current_timestamp - 10
union
select count(distinct ad.session) from accessdetails ad
having max(ad.recorded) > current_timestamp - 10
The first, which could be helped with an index, returns a smaller
value than the second from the accessdetails, which is a large table
of
1000s of simulatesd test users. The differance was 400 when the second
returned 5000 counts.
Anyone got an idea why they are different ?
Cheers,
Ivar
And I was comparing the speeds ,
when I realised they were not returning the same value.
Both plans are natural.
select count(distinct ad.session) from accessdetails ad
where ad.recorded > current_timestamp - 10
union
select count(distinct ad.session) from accessdetails ad
having max(ad.recorded) > current_timestamp - 10
The first, which could be helped with an index, returns a smaller
value than the second from the accessdetails, which is a large table
of
1000s of simulatesd test users. The differance was 400 when the second
returned 5000 counts.
Anyone got an idea why they are different ?
Cheers,
Ivar