473,396 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Functional index definition

Hello list,

Is there a way to create indexes using functions like these:
substring(prod_no,8,4)
to_char(fkardex,'YYYYMM')
substr(facnum,1,2)

Help says is not possible but I would like to know if someone know an
undocumented/tricky way to get that done.

Thanks in advance

--
Josué Maldonado.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #1
2 1998

On Tue, 11 Nov 2003, [ISO-8859-1] Josué Maldonado wrote:
Hello list,

Is there a way to create indexes using functions like these:
substring(prod_no,8,4)
to_char(fkardex,'YYYYMM')
substr(facnum,1,2)

Help says is not possible but I would like to know if someone know an
undocumented/tricky way to get that done.


Not directly in 7.3 and earlier. You have to make a function that wraps
the function you want to call with static arguments like:

create function substring_8_4(text) returns text as
'select substring($1, 8, 4);' language 'sql' immutable;

In 7.4, the indexes have been approved to allow indexes on expressions
which allow the above (with an extra set of parens in the definition).

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2
Stephan Szabo wrote:
Thanks Stephan.

I forgot to say I'm using 7.3.4, your solutions worked fine.

On Tue, 11 Nov 2003, [ISO-8859-1] Josué Maldonado wrote:

Hello list,

Is there a way to create indexes using functions like these:
substring(prod_no,8,4)
to_char(fkardex,'YYYYMM')
substr(facnum,1,2)

Help says is not possible but I would like to know if someone know an
undocumented/tricky way to get that done.

Not directly in 7.3 and earlier. You have to make a function that wraps
the function you want to call with static arguments like:

create function substring_8_4(text) returns text as
'select substring($1, 8, 4);' language 'sql' immutable;

In 7.4, the indexes have been approved to allow indexes on expressions
which allow the above (with an extra set of parens in the definition).

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

--
Josué Maldonado.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike Mascari | last post by:
Let's assume I have a table like so: CREATE TABLE employees ( employeeid text not null, name text not null ); CREATE INDEX i_employees ON employees(lower(name)); Let's also assume that...
10
by: WantedToBeDBA | last post by:
Hi Friends, How to create the functional index in db2? Is it possible to do that? I refered in online doc. But i am unable to find anything.. Thanks, Thiru. WantedToBeDBA.
177
by: C# Learner | last post by:
Why is C syntax so uneasy on the eye? In its day, was it _really_ designed by snobby programmers to scare away potential "n00bs"? If so, and after 50+ years of programming research, why are...
5
by: pmelies | last post by:
One of our web servers is not handling requests for ASP.net pages. We get a "A dynamic link library (DLL) initialization routine failed." error message, though nothing is recorded in the event...
1
by: David Garamond | last post by:
I want to know how functional indexes are used "in the real world". Here are the common uses: * non-unique index on the first parts of a longish text field (SUBSTRING(field)) to save disk space,...
7
by: Janning Vygen | last post by:
Hi, i searched the docs and the archives and was really wondering that i have not found anything searching for "functional index primary key". i would like to have a table of members with...
4
by: Dennis Gearon | last post by:
Is the following example a good, and correct one, for using a functional index? (the 'flip_bits' function would have to be written, and for the correct size of bit(N) ): I think I came up with a...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
15
by: Lorenzo Stella | last post by:
Hi all, I haven't experienced functional programming very much, but now I'm trying to learn Haskell and I've learned that: 1) in functional programming LISTS are fundmental; 2) any "cycle" in FP...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.