小编Spe*_*lin的帖子

使用限制和顺序查询运行速度太慢

我有下表:

CREATE TABLE dpg2
(
  account_id integer NOT NULL,
  tank_id integer NOT NULL,
  battles integer,
  dmg integer,
  frags integer,
  wins integer,
  recent_battles integer[],
  recent_dmg integer[],
  recent_frags integer[],
  recent_wins integer[],
  dpg real,
  recent_ts timestamp with time zone[],
  recent_dpg real,
  CONSTRAINT dpg2_pkey PRIMARY KEY (account_id, tank_id)
)
Run Code Online (Sandbox Code Playgroud)

使用此索引:

CREATE INDEX dpg_tank_id_idx
  ON dpg2
  USING btree
  (tank_id, dpg DESC NULLS LAST);
Run Code Online (Sandbox Code Playgroud)

我运行了以下查询:

explain analyze
    select dpg2.account_id, tank_id, (select nickname from players2 where players2.account_id = dpg2.account_id), dpg2.battles, dpg,
                frags*1.0/dpg2.battles, wins*100.0/dpg2.battles, dpg2.recent_dpg
    from dpg2
    where …
Run Code Online (Sandbox Code Playgroud)

postgresql order-by limits postgresql-9.4

4
推荐指数
1
解决办法
5712
查看次数

标签 统计

limits ×1

order-by ×1

postgresql ×1

postgresql-9.4 ×1