Re: [SQL] Advice for index design

2013-04-11 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 Jorge Maldonado wrote: ... > What is a good index design approach? Maybe, setting simple separate > indexes (one for each field) would work fine if I need to > retrieve data in different combinatios, but I am not sure. Yes, just create separat

[SQL] Slow update with ST_Contians()

2013-04-11 Thread androclos
UPDATE tbl SET city=s.city_name FROM shp AS s WHERE ST_CONTAINS(s.city_geom,geom); With the code above i can add exact city to a GPS point. It runs about 45-50 min on 50 million rows. There are about 4000 cities in the "city" table that have to be checked. I have another shape file with 19 counti

[SQL] Restrict FOREIGN KEY to a part of the referenced table

2013-04-11 Thread Matthias Nagel
Hello, is there any best practice method how to create a foreign key that only allows values from those rows in the referenced table that fulfill an additional condition? First I present two pseudo solutions to clarify what I would like to do. They are no real solutions, because they are neith