How optimize SQL query with location search in large radius
Summary The given PostgreSQL query is optimized for cursor-based paging using indexes on activity_date and id, as well as birth_date and gender. However, the addition of the spatial search condition ST_DWithin(location, ST_MakePoint(?, ?), 20000) significantly slows down the query execution. This article aims to explore the root cause of this issue and provide optimization strategies. … Read more