Subject | Re: [firebird-support] "EXTRACT (YEAR FROM DT.DATA) <= 2016" or "DT.DATA <= '12/31/2016'" |
---|---|
Author | Tim Ward |
Post date | 2016-12-09T11:44:18Z |
Generate and look at the query plan, then run the query and look at the
statistics.
It would be a clever optimiser that would have specific code to analyse
EXTRACT (YEAR FROM DT.DATA) <= 2016
and work out that it could use an index (rather than just saying "oh,
the stuff to the left of the <= is just a general expression, so I'll
have to calculate it for every record"), whereas
DT.DATA <= '12/31/2016'
needs no such cleverness. One might therefore reasonable expect that,
using *any* RDBMS, the first approach is rather more likely to end up as
a table scan.
But if you really want to know, generate and look at the query plan and
statistics, on a table with realistic data and production indexes.
On 09/12/2016 11:35, Luigi Siciliano luigisic@...
[firebird-support] wrote:
Tim Ward
statistics.
It would be a clever optimiser that would have specific code to analyse
EXTRACT (YEAR FROM DT.DATA) <= 2016
and work out that it could use an index (rather than just saying "oh,
the stuff to the left of the <= is just a general expression, so I'll
have to calculate it for every record"), whereas
DT.DATA <= '12/31/2016'
needs no such cleverness. One might therefore reasonable expect that,
using *any* RDBMS, the first approach is rather more likely to end up as
a table scan.
But if you really want to know, generate and look at the query plan and
statistics, on a table with realistic data and production indexes.
On 09/12/2016 11:35, Luigi Siciliano luigisic@...
[firebird-support] wrote:
> Hallo,--
>
> what is more performant from subject?
>
> I would prepare myself for a table that grows rapidly.
>
> Is the same in FB 2.5.6 or 3.0.1?
>
> Thanks
Tim Ward