Re: [QUESTION/PROPOSAL] loose quadtree in spgist - Mailing list pgsql-hackers
From | Tomas Vondra |
---|---|
Subject | Re: [QUESTION/PROPOSAL] loose quadtree in spgist |
Date | |
Msg-id | 20200107225634.ffeerzx2gme7x5im@development Whole thread Raw |
In response to | [QUESTION/PROPOSAL] loose quadtree in spgist (Peter Griggs <petergriggs33@gmail.com>) |
Responses |
Re: [QUESTION/PROPOSAL] loose quadtree in spgist
|
List | pgsql-hackers |
On Tue, Jan 07, 2020 at 11:33:31AM -0500, Peter Griggs wrote: >Hello, I wanted some guidance/suggestions about creating an spgist >extension. For context, i am a grad student doing research that involves >comparing the performance of different indexes for spatial data. We've >built a system that uses Postgres and one of the data structures we want to >use is a loose quadtree, but there is no implementation of this data >structure in spgist. The reason why I think this is pretty do-able is that >it is quite similar to a quadtree on boxes, which is implemented in >src/backend/utils/adt/geo_spgist.c. > >Additionally, I found by grepping through the repo for the existing >functions in spgist/box_ops operator class that several catalog files need >to be updated to reflect a new operator class in spgist. The files that I >believe need to be changed to create a new >spgist_loose_box_ops operator class are: > >src/include/catalog/pg_amop.dat >src/include/catalog/pg_amproc.dat >src/include/catalog/pg_opclass.dat >src/include/catalog/pg_opfamily.dat > You should probably try using CREATE OPERATOR CLASS command [1], not modify the catalogs directly. That's only necessary for built-in index types (i.e. available right after initdb). But you mentioned you're working on an extension, so the command is the right thing to do (after all, you don't know OIDs of objects from the extension). [1] https://www.postgresql.org/docs/current/sql-createopclass.html > >I've poked around quite a bit in the spgist code and have tried making >minimal changes to geo_spgist.c, but I haven't done any development on >postgres before, so i'm running into some issues that I couldn't find help >with on the postgres slack, by searching the mailing list, or by scouring >the development wikis. Well, learning the ropes may take a bit of time, and pgsql-hackers is probably the right place to ask ... >For example, I wanted to just print out some data to >see what quadrant a box is being placed into in the geo_spgist.c code. I >understand that printing to stdout won't work in postgres, but I thought >that I could possibly write some data to the logfile. I tried updating a >function to use both elog and ereport and re-built the code. However, I >can't get anything to print out to the logfile no matter what I try. Does >anyone have tips for printing out and debugging in general for postgres >development? > Well, elog/ereport are the easiest approach (it's what I'd do), and they do about the same thing. The main difference is that ereport allows translations of messages to other languages, while elog is for internal things that should not happen (unexpected errors, ...). For debugging just use elog(), I guess. It's hard to say why you're not getting anything logged, because you haven't shown us any code. My guess is that you're uring log level that is not high enough to make it into the log file. The default config in postgresql.conf says log_min_messages = warning which means the level has to be at least WARNING to make it into the file. So either WARNING, ERROR, LOG, FATAL, PANIC. So for example elog(INFO, "test message"); won't do anything, but elog(LOG, "test message"); will write stuff to the log file. If you use WARNING, you'll actually get the message on the client console (well, there's client_min_messages but you get the idea). > >Any tips or guidance would be much appreciated. Also, if there's a >different route I should go to turn this into a proposal for a patch >please let me know. I'm new to postgres dev. > A general recommendation is to show snippets of code, so that people on this list actually can help without too much guessing what you're doing. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
pgsql-hackers by date: