Commit 0345d20
Batch VM and host lookups in StorageManagerImpl to eliminate N+1 queries during cleanup and pool connect
cleanupStorage: replaced per-volume _vmInstanceDao.findById(vol.getInstanceId())
with a single batch SELECT ... WHERE id IN (...) before the loop, using a
HashMap for O(1) lookups. Added null guard for volumes with null instanceId.
connectHostsToPool: replaced per-thread _hostDao.findById(hostId) with a
batch load before thread pool submission. Each thread now reads from a
pre-built HashMap instead of hitting the DB. Added null guard with warning
log for hosts removed between list assembly and batch read.
Added VMInstanceDao.listByIds(List<Long>) with empty-list guard and IN-clause
SearchBuilder, matching the established pattern in HostDao.1 parent 6bc83a3 commit 0345d20
3 files changed
Lines changed: 34 additions & 2 deletions
File tree
- engine/schema/src/main/java/com/cloud/vm/dao
- server/src/main/java/com/cloud/storage
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1352 | 1352 | | |
1353 | 1353 | | |
1354 | 1354 | | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
1355 | 1368 | | |
Lines changed: 19 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1846 | 1846 | | |
1847 | 1847 | | |
1848 | 1848 | | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
1849 | 1853 | | |
1850 | 1854 | | |
1851 | 1855 | | |
| |||
1856 | 1860 | | |
1857 | 1861 | | |
1858 | 1862 | | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
1859 | 1868 | | |
1860 | 1869 | | |
1861 | 1870 | | |
1862 | | - | |
1863 | 1871 | | |
1864 | 1872 | | |
1865 | 1873 | | |
| |||
2126 | 2134 | | |
2127 | 2135 | | |
2128 | 2136 | | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
2129 | 2146 | | |
2130 | 2147 | | |
2131 | | - | |
| 2148 | + | |
2132 | 2149 | | |
2133 | 2150 | | |
2134 | 2151 | | |
| |||
0 commit comments