Я создал индекс для поля 'workflow.status'
, но почему после создания индекса время выполнения запроса увеличивается?
Запрос:
select workflow.* from
(
SELECT CASE
WHEN cert.value = 'true' THEN 0
ELSE 1 END lawAndOrder, workflow.*
FROM testdb.statuschanges hist, testdb.usercerts cert, testdb.workflow
WHERE workflow.taskid = hist.taskid AND hist.username = cert.username AND cert.projectname = 'Core_EECA_RUS_2018_shp_UPDGeo_LL' AND cert.key = 'DISABLECOMMIT'
AND hist.statuschangeid =workflow.proposedstatuschangeid AND workflow.status in ('Check')and workflow.projectname = 'Core_EECA_RUS_2018_shp_UPDGeo_LL' AND workflow.claimedby IS NULL
UNION
SELECT CASE
WHEN workflow.status = 'INProgress' THEN 1
WHEN workflow.status = 'Feedback' THEN 2
WHEN workflow.status not in ('Check', 'INProgress', 'Feedback') THEN 3
END lawAndOrder,workflow.*
FROM testdb.workflow
WHERE workflow.status != 'Check' AND workflow.claimedby IS NULL AND workflow.projectname = 'Core_EECA_RUS_2018_shp_UPDGeo_LL' order by lawAndOrder ASC, TaskId
)
workflow WHERE ProjectName = 'Core_EECA_RUS_2018_shp_UPDGeo_LL' AND
Status IN ('SourcedFromGuidedCommunity', 'NeedsWorkInTIF', 'NeedsFieldCollection', 'INProgress', 'Completed', 'Check', 'New', 'Reject', 'In Testing', 'Check Reject', 'Check Accept with minor remark', 'InQA', 'Rework', 'Feedback')
AND ClaimedBy IS NULL
Индексоператор создания:
CREATE INDEX idx_workflow_status
ON testdb.workflow
USING btree
(status COLLATE pg_catalog."default");
Возможно ли увеличение индекса времени?