Skip to content

Instantly share code, notes, and snippets.

@recurse-id
Last active August 8, 2020 14:39
Show Gist options
  • Save recurse-id/6107150 to your computer and use it in GitHub Desktop.
Save recurse-id/6107150 to your computer and use it in GitHub Desktop.
Some tips on creating pl/python functions in psql
1) instead of returning SETOF composite_type or SETOF RECORD (OUT col type) return TABLE (col type,etc) and just yield.
2) For long queries in plpy.execute use triple quotes for multiline queries
3) use explain [query] to figure out what is taking so much time on a query then build indexes to remove the "sequential scans"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment