Greg Stark wrote: > On Sun, Nov 9, 2014 at 5:57 PM, Greg Stark <st...@mit.edu> wrote: > > 2) The mention about additional opclass operators and to number them > > from 11 up is fine -- but there's no explanation of how to decide what > > operators need to be explicitly added like that. Specifically I gather > > from reading minmax that = is handled internally by Brin and you only > > need to add any other operators aside from = ? Is that right? > > I see I totally misunderstood the use of the opclass procedure > functions. I think I understand now but just to be sure -- If I can > only handle BTEqualStrategyNumber keys then is it adequate to just > define the opclass containing only the equality operator?
Yes. I agree that this deserves some more documentation. In a nutshell, the opclass must provide three separate groups of items: 1. the mandatory support functions, opcInfo, addValue, Union, Consistent. opcInfo is invoked each time the index is accessed (including during index creation). 2. the additional support functions; normally these are called from within addValue, Consistent, Union. For minmax, what we provide is the functions that implement the inequality operators for the type, that is < <= => and >. Since minmax tries to be generic and support a whole lot of types, this is the way that the mandatory support functions know what functions to call to compare two given values. If the opclass is specific to one data type, you might not need anything here; or perhaps you have other ways to figure out a hash function to call, etc. 3. the operators. We only use these so that the optimizer picks up the index for queries. > Somehow I got confused between the amprocs that minmax uses to > implement the consistency function and the amops that the brin index > supports. I think it is somewhat confusing, yeah. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers