call_date should be the first index column.
This results in a huge speedup
This commit is contained in:
parent
2d9c9e8ef5
commit
84ebd7e959
2 changed files with 2 additions and 2 deletions
|
@ -104,7 +104,7 @@ CREATE TABLE IF NOT EXISTS calls(
|
||||||
) PARTITION BY RANGE (call_date);
|
) PARTITION BY RANGE (call_date);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS calls_transcript_idx ON calls USING GIN (to_tsvector('english', transcript));
|
CREATE INDEX IF NOT EXISTS calls_transcript_idx ON calls USING GIN (to_tsvector('english', transcript));
|
||||||
CREATE INDEX IF NOT EXISTS calls_call_date_tg_idx ON calls(system, talkgroup, call_date);
|
CREATE INDEX IF NOT EXISTS calls_call_date_tg_idx ON calls(call_date, talkgroup, system);
|
||||||
|
|
||||||
CREATE TABLE swept_calls (
|
CREATE TABLE swept_calls (
|
||||||
id UUID PRIMARY KEY,
|
id UUID PRIMARY KEY,
|
||||||
|
|
|
@ -76,6 +76,7 @@ VALUES
|
||||||
SELECT pg_size_pretty(pg_database_size(current_database()));
|
SELECT pg_size_pretty(pg_database_size(current_database()));
|
||||||
|
|
||||||
-- name: SweepCalls :execrows
|
-- name: SweepCalls :execrows
|
||||||
|
-- This is used to sweep calls that are part of an incident prior to pruning a partition.
|
||||||
WITH to_sweep AS (
|
WITH to_sweep AS (
|
||||||
SELECT id, submitter, system, talkgroup, calls.call_date, audio_name, audio_blob, duration, audio_type,
|
SELECT id, submitter, system, talkgroup, calls.call_date, audio_name, audio_blob, duration, audio_type,
|
||||||
audio_url, frequency, frequencies, patches, tg_label, tg_alpha_tag, tg_group, source, transcript
|
audio_url, frequency, frequencies, patches, tg_label, tg_alpha_tag, tg_group, source, transcript
|
||||||
|
@ -85,7 +86,6 @@ WITH to_sweep AS (
|
||||||
) INSERT INTO swept_calls SELECT * FROM to_sweep;
|
) INSERT INTO swept_calls SELECT * FROM to_sweep;
|
||||||
|
|
||||||
-- name: CleanupSweptCalls :execrows
|
-- name: CleanupSweptCalls :execrows
|
||||||
-- This is used to sweep calls that are part of an incident prior to pruning a partition.
|
|
||||||
WITH to_sweep AS (
|
WITH to_sweep AS (
|
||||||
SELECT id FROM calls
|
SELECT id FROM calls
|
||||||
JOIN incidents_calls ic ON ic.call_id = calls.id
|
JOIN incidents_calls ic ON ic.call_id = calls.id
|
||||||
|
|
Loading…
Reference in a new issue