Commit 6d851ab
Add source filter and indexed hash prefix to cert tag batch query (open-metadata#27847)
* Add source filter and use indexed hash prefix in cert tag batch query
The certification tag batch query (TagUsageDAO.getCertTagsInternalBatch)
was hitting ~12 seconds per call on instances with deep classification
hierarchies — fired ~5,800 times per Data Insights run, contributing
~19 hrs of cumulative DB time per DI run.
Two missing index-friendly predicates caused the slowness:
1. No `source = ?` filter — couldn't use idx_tag_usage_target_exact
(source, targetFQNHash, state) INCLUDE (tagFQN, labelType) whose
covering INCLUDE has tagFQN.
2. `tagFQN LIKE 'Certification.%'` on the raw column — there's no
LIKE-friendly index on raw tagFQN, only on tagfqn_lower text_pattern_ops
and tagFQNHash. The LIKE always ran as a post-filter on every row the
IN clause returned.
Fix:
- Add `source = :source` filter (Certifications are always Classification
source = 0).
- Switch `tagFQN LIKE :tagFQNPrefix` → `tagFQNHash LIKE :tagFQNHashPrefix`,
with the hash prefix pre-computed via FullyQualifiedName.buildHash so the
query hits the indexed hash column.
Same SQL on MySQL and Postgres — no @ConnectionAwareSqlQuery split needed.
Also a correctness improvement: the `source = 0` filter excludes glossary
terms (source = 1) that happen to have FQNs starting with "Certification.".
Previously such glossary terms could be incorrectly returned as
certifications; now they're excluded as expected.
Test:
- Added test_certBatch_bulkFetchReturnsCorrectCertsPerEntity in
TagResourceIT — exercises the bulk fetch path with three schemas
(cert-tagged / untagged / non-cert-tagged) and asserts each gets
the right certification (or null) in the listed response. Locks in
source-filter correctness and prevents future regressions where a
non-cert tag could leak into the certification field.
* Fix duplicate schema names in cert batch test, trim verbose comments
* Update EntityRepositoryCertificationTest mocks for new getCertTagsInternalBatch signature
* fix check style1 parent 3148527 commit 6d851ab
4 files changed
Lines changed: 126 additions & 14 deletions
File tree
- openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests
- openmetadata-service/src
- main/java/org/openmetadata/service/jdbi3
- test/java/org/openmetadata/service/jdbi3
Lines changed: 98 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1578 | 1578 | | |
1579 | 1579 | | |
1580 | 1580 | | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
1581 | 1679 | | |
1582 | 1680 | | |
1583 | 1681 | | |
| |||
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6250 | 6250 | | |
6251 | 6251 | | |
6252 | 6252 | | |
6253 | | - | |
6254 | | - | |
| 6253 | + | |
| 6254 | + | |
| 6255 | + | |
6255 | 6256 | | |
6256 | 6257 | | |
6257 | 6258 | | |
| 6259 | + | |
6258 | 6260 | | |
6259 | | - | |
| 6261 | + | |
6260 | 6262 | | |
6261 | 6263 | | |
6262 | 6264 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4968 | 4968 | | |
4969 | 4969 | | |
4970 | 4970 | | |
4971 | | - | |
| 4971 | + | |
| 4972 | + | |
| 4973 | + | |
4972 | 4974 | | |
4973 | 4975 | | |
4974 | 4976 | | |
| |||
9642 | 9644 | | |
9643 | 9645 | | |
9644 | 9646 | | |
9645 | | - | |
| 9647 | + | |
| 9648 | + | |
| 9649 | + | |
| 9650 | + | |
| 9651 | + | |
| 9652 | + | |
9646 | 9653 | | |
9647 | 9654 | | |
9648 | 9655 | | |
| |||
Lines changed: 14 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
209 | | - | |
| 210 | + | |
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
230 | | - | |
| 231 | + | |
| 232 | + | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| |||
282 | 284 | | |
283 | 285 | | |
284 | 286 | | |
285 | | - | |
| 287 | + | |
| 288 | + | |
286 | 289 | | |
287 | 290 | | |
288 | 291 | | |
| |||
393 | 396 | | |
394 | 397 | | |
395 | 398 | | |
396 | | - | |
| 399 | + | |
| 400 | + | |
397 | 401 | | |
398 | 402 | | |
399 | 403 | | |
| |||
415 | 419 | | |
416 | 420 | | |
417 | 421 | | |
418 | | - | |
| 422 | + | |
419 | 423 | | |
420 | 424 | | |
421 | 425 | | |
| |||
433 | 437 | | |
434 | 438 | | |
435 | 439 | | |
436 | | - | |
| 440 | + | |
437 | 441 | | |
438 | 442 | | |
439 | 443 | | |
| |||
568 | 572 | | |
569 | 573 | | |
570 | 574 | | |
571 | | - | |
| 575 | + | |
| 576 | + | |
572 | 577 | | |
573 | 578 | | |
574 | 579 | | |
| |||
0 commit comments