PostgreSQL query very slow with limit 1

前端 未结 3 985
猫巷女王i
猫巷女王i 2020-11-30 03:22

My queries get very slow when I add a limit 1.

I have a table object_values with timestamped values for objects:

 timestam         


        
3条回答
  •  悲&欢浪女
    2020-11-30 04:24

    I started having similar symptoms on an update-heavy table, and what was needed in my case was

    analyze $table_name;
    

    In this case the statistics needed to be refreshed, which then fixed the slow query plans that were occurring.
    Supporting docs: https://www.postgresql.org/docs/current/sql-analyze.html

提交回复
热议问题