smartcontractkit / ccip

Cross Chain Interoperability Protocol
Other
119 stars 47 forks source link

Add id column as PRIMARY KEY for evm.logs & evm.log_poller_blocks #1441

Open reductionista opened 1 month ago

reductionista commented 1 month ago

Problem:

The query for pruning expired logs with a max limit set was taking longer than it should. This was part due to needing to join on an awkward combination combination of columns due to their being no single primary key.

Solution:

While adding the id column, we can't just remove the old primary key because the index on it was helping to accelerate some queries. Instead of just resurrecting it as-is, I took the opportunity to clean up several of the indices on the logs & blocks table. Some indexed columns (eg created_at) were never actually being used, while others were not ordered in the most optimal way for accelerating the queries we have. Also, at least one of them was redundant with the primary key just in a different order.

cl-sonarqube-production[bot] commented 3 weeks ago

Quality Gate failed Quality Gate failed

Failed conditions
42.2% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube