Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add an index in table resource_view to improve DB performance #7134

@FuhuXia

Description

@FuhuXia

CKAN version
2.9.6, master

Describe the bug
Table resource_view needs a index on column resource_id.

Steps to reproduce
In a big CKAN database (500k packages) run the query

begin;
explain (analyze,buffers,timing)
delete from resource where package_id = [###];                                  
rollback;
...
Trigger for constraint resource_view_resource_id_fkey: time=68.124 calls=6

Expected behavior

CREATE INDEX idx_view_resource_id
ON resource_view(resource_id);

After the index added, the time dropped from 68.124 to 0.420, that is 170 times faster.

Additional details
This will greatly reduce time spent when clearing a big harvest source.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions