• Deni

    (@dennis_f)


    Hi All,

    I wanted to ask if we are allowed to create indexes in the default WordPress tables with a plugin?
    I’m working on a plugin that makes a database query (using left join to join two tables), which is extremely slow due to the lack of index to one of the columns.
    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • RossMitchell

    (@rossmitchell)

    It is your site, I can’t see why this would be a problem. The create indexes code will only need to be run once, say when the plugin gets activated, give the plugin a suitable description in the Dashboard and you are safe. Maybe remove the indexes when the plugin is deactivated ?

    Be aware that creating and maintaining indexes has its own cost, so it is possible (though unlikely) that you are just moving your processing overhead to somewhere else, the behaviour of your site will tell you if this happens.

    Thread Starter Deni

    (@dennis_f)

    Hi there,

    Thank you for your reply.

    I’m working on a plugin that I’m planning to release here on www.ads-software.com, so it’s not only for my site.
    A simple left join between the users and comments table is really slow with higher number of records, because of the lack of index on the user_id column in the comments table – I tested adding an index to that column on my site and it works really fast.
    So, I wanted to ask if adding an index to a default WordPress table would be something that is allowed to be performed in a plugin? I’ve been concerned that this might not be a good practice either.
    Many thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Database indexes’ is closed to new replies.