I am using python/django as for programming language/framework. What i need to know is totally about postgresql and indexing...
For those who uses django probably know Content Type and Django Admin Log. But shortly, Admin log is logging user action. I also use it for logging all actions performed within the site. So it has 1.000.000+ records. I use sql queries to filter results, Thats ok up to here...
Problem is, i use two fields to select data from diffrent tables. One of them is, content type, which stores the related database table info and the field is indexed...
Other field is, object id, which stores id of the related object, the field type is varchar and field is not indexed...
Examle of usage is :
Select from django_admin_log where content_type_id=15 and object_id="12343545";
Since content_type_id=15 points my blog_texts table and the id of the related object is 12343545, i can easily get related data...
But object_id is not indexed, and table have 1.000.000+ records, a query like i write above takes a lot of execution time.
What will be the benefits and drawbacks of using index in object_id. Will the benefits be greated than drawbacks or not?
UPDATE: I have no updates on admin log table. It just logs each of all user actions... 40.000-45.000 records are inserted to the table each day. And system is really busy during 2/3 of the day, about 15-16 hours (morning to evening). So 45.000 records are inserted during 8.00am to 11.00pm...
So at this point of view, will it cause too much database overwight if i create indexes?
UPDATE 2: One more question. Another table with 2.000.000+ records with a boolean field. Field is something like "wwill it be displayed", and it is used with other filter criteria. Is it logical to create an index for a such boolean field.
Second conditin is, indexing a boolean and a datetime fields together in a table with 1.000.000 records...
Using index for these two condition is a good idea or not?