Re: [firebird-support] Help creating expression index

2019-07-17 Thread 'Mr. John' mr_joh...@yahoo.com [firebird-support]
 great solutionthanks!

On Wednesday, July 17, 2019, 06:59:44 PM GMT+3, Dimitry Sibiryakov 
s...@ibphoenix.com [firebird-support]  wrote: 
 
 
 17.07.2019 17:54, 'Mr. John' mr_joh...@yahoo.com [firebird-support] wrote:
> I want to create a index to improve a query like that:
>      SELECT * FROM MYTABLE WHERE EXTRACT(YEAR FROM datein)=2019  AND 
>EXTRACT(MONTH FROM 
> datein)=1

  Rewrite it as

SELECT * FROM MYTABLE WHERE datein between date '2019-01-01' and date 
'2019-02-01'

  Then you can create an ordinary index for datein.


-- 
  WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links



  

Re: [firebird-support] Help creating expression index

2019-07-17 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
17.07.2019 17:54, 'Mr. John' mr_joh...@yahoo.com [firebird-support] wrote:
> I want to create a index to improve a query like that:
>      SELECT * FROM MYTABLE WHERE EXTRACT(YEAR FROM datein)=2019  AND 
> EXTRACT(MONTH FROM 
> datein)=1

   Rewrite it as

SELECT * FROM MYTABLE WHERE datein between date '2019-01-01' and date 
'2019-02-01'

   Then you can create an ordinary index for datein.


-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] Help creating expression index

2019-07-17 Thread 'Mr. John' mr_joh...@yahoo.com [firebird-support]
HiI want to create a index to improve a query like that:    SELECT * FROM 
MYTABLE  WHERE EXTRACT(YEAR FROM datein)=2019  AND EXTRACT(MONTH FROM datein)=1

I can create this index:   CREATE DESCENDING MYINDEX ON MYTABLE  COMPUTED BY 
(EXTRACT(YEAR FROM datein) || EXTRACT(MONTH FROM datein) )
 and change the query:
   SELECT * FROM MYTABLE  WHERE EXTRACT(YEAR FROM datein)|| EXTRACT(MONTH FROM 
datein)='20191'

index is used,but don't think this is the solution


thanks for any help