29th / personnel-v3

Personnel management system version 3
https://www.29th.org
2 stars 6 forks source link

Upgrade ancestry format and ensure indexed #290

Open wilson29thid opened 3 months ago

wilson29thid commented 3 months ago

There's a new format for the ancestry column which is more performant. Also, there's guidance on indexing that we'll want to make sure we follow. This column is used a lot so should make a noticeable difference.

https://github.com/stefankroes/ancestry

If we want to use the path column:

Or if we want to continue calling it ancestry:

Finally:

wilson29thid commented 3 months ago

It looks like the paths are all up-to-date already, thanks to the callback we've had in place in the Unit model. There are 3 root-level units, one of which has a NULL path (Regt HQ), and 13 TPs that have NULL ancestry for some reason.

select id, abbr, path, ancestry
FROM units
where path != concat('/', ancestry, '/')
    or path is null or ancestry is null
id abbr path ancestry
595 Admins /
624 SLT /
1631 Regt. HQ
1634 1522nd TP /1631/361/362/486/43/
1635 1523rd TP /1631/361/362/486/43/
1636 1524th TP /1631/361/362/486/43/
1645 1525th TP /1631/361/362/486/43/
1646 1526th TP /1631/361/362/486/43/
1647 1527th TP /1631/361/362/486/43/
1648 1528th TP /1631/361/362/486/43/
1649 1529th TP /1631/361/362/486/43/
1650 1530th TP /1631/361/362/486/43/
1651 1531st TP /1631/361/362/486/43/
1652 1532nd TP /1631/361/362/486/43/
1653 1533rd TP /1631/361/362/486/43/
1654 1534th TP /1631/361/362/486/43/
wilson29thid commented 3 months ago

So we can't use the column name "path" with the ancestry gem because ancestry already uses that term as a concept.