postgis-skill

Provide PostGIS SQL best practices, performance tips, and debugging guidance.

Updated Apr 11, 2024
One-click install
npx skills add https://github.com/codacy-open-source-projects-scans/postgis --skill postgis-skill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgis-skill
Source: https://github.com/codacy-open-source-projects-scans/postgis/tree/main/doc
Command: npx skills add https://github.com/codacy-open-source-projects-scans/postgis --skill postgis-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostGIS users often struggle with writing robust, efficient SQL for geospatial data, suffering from unreadable queries, inconsistent conventions, and missed optimization opportunities.

Core Features & Use Cases

  • Guidelines and best practices for PostGIS SQL readability, commenting, and naming conventions.
  • Performance tips including indexing hints, query refactor strategies, and debugging techniques.
  • Use Case: A developer cleans up a complex spatial query and adds proper comments and an index to speed up ST_Intersects on large datasets.

Quick Start

Use the postgis-skill to audit a spatial table for commented create statements and suggest a index on the geometry column, then apply the recommended changes to improve clarity and performance.

Frequently Asked Questions about postgis-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize slow PostGIS SQL queries on large geospatial datasets?

Optimize slow PostGIS SQL queries by applying indexing hints on geometry columns and refactoring spatial joins. Adding indexes to geometry columns speeds up functions like ST_Intersects, significantly improving query performance on large geospatial datasets.

What are the best practices for writing readable PostGIS SQL?

Best practices for readable PostGIS SQL include following consistent naming conventions, adding clear comments to complex spatial logic, and structuring queries cleanly. These conventions reduce errors and make geospatial data workflows easier to maintain.

How do I debug complex spatial queries in PostGIS?

Debug complex spatial queries in PostGIS by applying targeted debugging techniques to isolate faulty geometry operations. Auditing spatial tables for missing indexes or malformed geometries helps identify and resolve performance bottlenecks effectively.

When do I need a spatial index for ST_Intersects in PostGIS?

You need a spatial index for ST_Intersects in PostGIS when querying large geospatial datasets to prevent full table scans. Creating an index on the geometry column allows the database to quickly filter intersecting bounding boxes before executing exact geometry checks.

Can I use this PostGIS skill to audit existing spatial tables?

Yes, you can use this skill to audit existing spatial tables for missing comments on create statements and identify geometry columns lacking indexes. It provides actionable instructions to apply recommended changes for improved query clarity and performance.

Why does my PostGIS query ignore the geometry index?

A PostGIS query might ignore a geometry index due to malformed query syntax or missing spatial constraints. Reviewing query refactor strategies and applying proper indexing hints ensures the query planner utilizes the index for geospatial data retrieval.