forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit42f70cd
committed
Improve performance of tuple conversion map generation
Previously convert_tuples_by_name_map naively performed a search of eachoutdesc column starting at the first column in indesc and searched eachindesc column until a match was found. When partitioned tables had manycolumns this could result in slow generation of the tuple conversion maps.For INSERT and UPDATE statements that touched few rows, this could mean avery large overhead indeed.We can do a bit better with this loop. It's quite likely that the columnsin partitioned tables and their partitions are in the same order, so itmakes sense to start searching for each column outer column at the innercolumn position 1 after where the previous match was found (per idea fromAlexander Kuzmenkov). This makes the best case search O(N) instead ofO(N^2). The worst case is still O(N^2), but it seems unlikely that wouldhappen.Likewise, in the planner, make_inh_translation_list's search for thematching column could often end up falling back on an O(N^2) type search.This commit also improves that by first checking the column that followsthe previous match, instead of the column with the same attnum. If wefail to match here we fallback on the syscache's hashtable lookup.Author: David RowleyReviewed-by: Alexander KuzmenkovDiscussion:https://www.postgresql.org/message-id/CAKJS1f9-wijVgMdRp6_qDMEQDJJ%2BA_n%3DxzZuTmLx5Fz6cwf%2B8A%40mail.gmail.com1 parent130beba commit42f70cd
File tree
2 files changed
+47
-28
lines changed- src/backend
- access/common
- optimizer/prep
2 files changed
+47
-28
lines changedLines changed: 28 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
295 | 295 |
| |
296 | 296 |
| |
297 | 297 |
| |
298 |
| - | |
| 298 | + | |
| 299 | + | |
299 | 300 |
| |
| 301 | + | |
300 | 302 |
| |
301 |
| - | |
302 |
| - | |
303 |
| - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
304 | 308 |
| |
305 | 309 |
| |
306 | 310 |
| |
| |||
313 | 317 |
| |
314 | 318 |
| |
315 | 319 |
| |
316 |
| - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
317 | 333 |
| |
318 |
| - | |
| 334 | + | |
319 | 335 |
| |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
320 | 341 |
| |
321 | 342 |
| |
322 | 343 |
| |
| |||
330 | 351 |
| |
331 | 352 |
| |
332 | 353 |
| |
333 |
| - | |
| 354 | + | |
334 | 355 |
| |
335 | 356 |
| |
336 | 357 |
| |
| |||
343 | 364 |
| |
344 | 365 |
| |
345 | 366 |
| |
346 |
| - | |
347 | 367 |
| |
348 | 368 |
| |
349 | 369 |
| |
|
Lines changed: 19 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
| 54 | + | |
54 | 55 |
| |
55 | 56 |
| |
56 | 57 |
| |
| |||
1895 | 1896 |
| |
1896 | 1897 |
| |
1897 | 1898 |
| |
| 1899 | + | |
1898 | 1900 |
| |
1899 | 1901 |
| |
1900 | 1902 |
| |
| 1903 | + | |
1901 | 1904 |
| |
1902 | 1905 |
| |
1903 | 1906 |
| |
| |||
1906 | 1909 |
| |
1907 | 1910 |
| |
1908 | 1911 |
| |
1909 |
| - | |
1910 | 1912 |
| |
1911 | 1913 |
| |
1912 | 1914 |
| |
| |||
1939 | 1941 |
| |
1940 | 1942 |
| |
1941 | 1943 |
| |
1942 |
| - | |
1943 |
| - | |
1944 |
| - | |
1945 |
| - | |
1946 |
| - | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
1947 | 1948 |
| |
1948 |
| - | |
1949 |
| - | |
1950 |
| - | |
1951 |
| - | |
1952 |
| - | |
1953 |
| - | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
1954 | 1952 |
| |
1955 |
| - | |
1956 |
| - | |
1957 |
| - | |
1958 |
| - | |
1959 |
| - | |
1960 |
| - | |
1961 |
| - | |
1962 |
| - | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
1963 | 1957 |
| |
1964 | 1958 |
| |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
1965 | 1963 |
| |
1966 | 1964 |
| |
1967 | 1965 |
| |
| |||
1978 | 1976 |
| |
1979 | 1977 |
| |
1980 | 1978 |
| |
| 1979 | + | |
1981 | 1980 |
| |
1982 | 1981 |
| |
1983 | 1982 |
| |
|
0 commit comments
Comments
(0)