shatteredsilicon / ssm-submodules

GNU Affero General Public License v3.0
0 stars 2 forks source link

Additional Index on SSM QAN Database #211

Closed gordan-bobic closed 8 months ago

gordan-bobic commented 8 months ago

Queries like this are run when deleting database servers from monitoring:

DELETE qcm
FROM query_class_metrics qcm
JOIN instances i ON qcm.instance_id = i.instance_id
WHERE i.uuid = '7cac38f91e0b4a3975409b3327612858';

This index is required to make those run well:

ALTER TABLE query_class_metrics ADD INDEX instance_id (instance_id), ALGORITHM=INPLACE, LOCK=NONE;

Additionally, if the instance is getting deleted, then the instance with matching the uuid should also be deleted, but it doesn't look like this happens. This should also run for the relevant instance uuid, unless I am missing something:

DELETE FROM instances WHERE uuid = '7cac38f91e0b4a3975409b3327612858';
oblitorum commented 8 months ago

Wait, regarding this issue, we alread added an instance_start (instance_id, start_at) index, do we still need a standalone instance_id index?

gordan-bobic commented 8 months ago

Ah, I forgot about that. Yes, that index will do. Closing this.