How do I run a query to identify which site is using which plugin?

I am trying to create a query I can run directly on the database to show what sites on a network are using a particular plugin. Do you know where the plugin info is stored that I could look at? Or even better, do you have a SQL query I could modify for my use that does something like this?

My database is overweight and I need to delete unused databases. I have over 4000 of them that needs to be checked for unused tables. I don't want to delete something I shouldn't be deleting and it's also hard to decipher each database by their name.

  • Ivan

    Hey there Serge,

    Hope you are having great week so far!

    Do you know where the plugin info is stored that I could look at?

    What do you want to do with it?
    Plugins are shared within the network and even if they are not used by a site, they might be used by another one.
    Even more - someone might want to disable a plugin for a period of time and if you delete the data in the database they might expect to have this data there and when they don't find it - you will get a lot of questions.

    The active plugins are stored in the wp_[blog_id]_options in the field 'active_plugins' and 'active_sitewide_plugins' in wp_[blog_id]_sitemeta. These are serialised fields so don't edit them unless you know what you're doing.
    I strongly advise not to modify them manually as this might ruin a lot of sites in the network.

    My database is overweight and I need to delete unused databases. I have over 4000 of them that needs to be checked for unused tables.

    Even if the database is not used lately that doesn't mean it is not needed.
    For a starting point you can use this SlackOverflow thread - http://stackoverflow.com/a/4056005
    There is very good comments on the mysql table usage there.

    This is more of a server side optimization and it is better to seek advise from server administrator or even hire one as this can be quite complicated task.

    Additionally you can try this plugin - https://wordpress.org/plugins/wp-optimize/
    To be honest I haven't use it myself, but it should help at least a little.

    Don't forget to make backups with so much information! :slight_smile:

    Thanks,
    Ivan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.