Opened 6 years ago

Closed 6 years ago

#30122 closed Cleanup/optimization (duplicate)

Add index in object_id column in LogEntry table to make fetch query faster.

Reported by: Shashank Parekh Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In history_view function, we use object_id and content_type to fetch the logs. Usually, we will have lots of entries based on content_type compare with object_id.

It is ideal to index object_id to make fetch query faster.

I can work on this task.

Change History (5)

comment:1 by Carlton Gibson, 6 years ago

Hi Shashank.

Without really looking, this seems reasonable.

What's the query being generated? Is that using a table scan? If so, you're just talking about adding an index right?

comment:2 by Simon Charette, 6 years ago

If we decide to add an index we should consider a composite (content_type_id, object_id) one and maybe make the content_type foreign key db_index=False given there's no use case for querying LogEntry by object_id without content_type_id and that most (if not all) supported database engines are able to use the first parts of a composite index rendering the content_type_id index useless.

comment:3 by Tim Graham, 6 years ago

Easy pickings: unset

Seems related to #23435: "GenericForeignKey should be indexed".

comment:4 by Claude Paroz, 6 years ago

I think this is a duplicate of #17659 (blocked because object_id is a TextField currently unindexable on MySQL). See also #28661.

comment:5 by Tim Graham, 6 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top