|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Имеется табличка Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32.
, тоесть F0|F1|01.03.2006|03.03.2006 F0|F2|03.03.2006|04.03.2006 F0|F1|04.03.2006|09.03.2006 Понимаю, что вроде бы как аналитические ф-ции, но немогу понять, сделать такое окно . Может кто подтолкнет в нужную сторону? Исходная табличка - 60 млн ------------------------------ Not affilated with VAZ ... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 13:30 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
КалинаНеобходимо объединить периоды для которых комбинация f0,f1 неизменна Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.
... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 13:51 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.
... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 13:56 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
КалинаИсходная табличка - 60 млн А расскажите потом, что она скажет на группировку? Мы в свое время не добились, чтобы группировка такого же объема проходила. ;( ... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 14:03 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Q u a d r o Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18.
еще и полей типа f1,f0 - дофига, 13 штук ... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 14:10 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
...может быть что-нибудь в этом духе?... ( если у Вас может быть "разделитель" ) Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.
... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 14:20 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Q u a d r o Код: plaintext 1. 2. 3. 4.
... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 15:32 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Since Исходная табличка - 60 млн, I would write a pipelined table function: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80.
In such case we deal with one ORDER BY versus windowing/partitioning + group by + order by. And if there is an index on F0,F1,SDATE,EDATE it might be not that bad. SY. ... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 17:20 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
One more thing - I assume intervals do not cross, otherwise it would be a bit more complex logic. SY. ... |
|||
:
Нравится:
Не нравится:
|
|||
16.03.2006, 17:24 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
SY I would write a pipelined table function how about "test it"? let's see how it goes. ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 02:58 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Q u a d r ohow about "test it"? Well, I provided test results against Калина's small sample. If you mean volume testing, provide a test case and I'll gladly do it. In any case, as I already noted, PL/SQL solution uses a single pass through a sorted table comparing to window sort, group by and order by. SY. ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 04:20 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
tkprof the analytics tkprof the pipelined function compare them pipelined mean "write a lot of code" - we need to justify this one. ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 04:40 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Q u a d r otkprof the analytics tkprof the pipelined function compare them You do not need tkprof to compare Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
and Код: plaintext 1. 2. 3. 4.
And tkprof can not evaluate PL/SQL portion of table function. Q u a d r opipelined mean "write a lot of code" - we need to justify this one. If avoiding partitioninig+window sort and group by on 60,000,000 rows is not enough, then I do not know what justification you are looking for. And BTW, I do not see any complexity in that table function. Anyway, below is my test: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75.
SY. ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 05:53 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
SY And tkprof can not evaluate PL/SQL portion of table function. Yes it can?? Anyway, you have only one combination of f0 and f1 - not a fair comparsion how about: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47.
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60.
pipelined is tad slower so "it depends" ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 06:17 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
But "group by" clause is not neccessary, we can use "over(partition by " on external query instead of "group by" and decrease sort operations ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 08:44 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
benchmark it. group by doesn't imply "sort", look above - hash group by - for you see ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 09:51 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
2 SY & Q u a d r o Спасибо за сравнение разных алгоритмов. Лично мне интуитивно гораздо больше нравится (исключительно с точки зрения потенции в производительности) вариант SY. Более того, в нём имеется запас для оптимизации путём уменьшения переключений контекста при помощи bulk-fetch (а в 10-ке и вообще просто for-select-loop). ______________________________________________________________________ 2 SkyNet77 Ты путаешь агрегацию с сортировкой. ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 10:01 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Мне лично вариант с Pipelined кажется не очень , но и SY и Elic - люди серьезные, в понедельник сделаю тестовый прогон на 1- млн , сравню все варианты ------------------------------ Not affilated with VAZ ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 10:22 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Вот, вроде еще не предлагали, для десятки. Работает медленно, зато красиво выглядит :)) Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28.
... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 14:22 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Well, I tried Quadro's test on my laptop: Код: plaintext 1. 2. 3.
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. 185. 186. 187. 188. 189. 190. 191. 192. 193. 194. 195. 196. 197. 198. 199. 200. 201. 202. 203. 204. 205. 206. 207. 208. 209. 210. 211. 212. 213. 214. 215. 216. 217. 218. 219. 220. 221. 222. 223. 224. 225. 226. 227. 228. 229. 230. 231. 232. 233. 234.
As you can see, with or without stats, pipelined table function is faster. Below are TKPROF results: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44.
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47.
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42.
Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53.
... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2006, 18:21 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Well... you have a little low workarea size :-) see - here is the problem: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.
7901 reads from disk Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21.
36463 reads from disk - you are swapping to temp like mad in this test see above - in my tests the disk was zero. analytics grabs more memory for hashing/sorting - and you don't have enough. Definitley it is not for laptops with 512 megs of ram :-) ... |
|||
:
Нравится:
Не нравится:
|
|||
19.03.2006, 03:18 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Q u a d r o36463 reads from disk - you are swapping to temp like mad in this test. Definitley it is not for laptops with 512 megs of ram :-) Absolutely. And it is, IMHO, good since if reflects (don't know how accurate though) scalability issue. In this case table has 1,000,000 rows while real one will have 60 times more. So even if just 1GB of memory takes care of 1,000,000 rows 60 million rows would need a bit more than that :). Q u a d r osee above - in my tests the disk was zero. Which tells me your test was not 100% cosher - you should have at least as many "disk" as it takes to read the table itself. Most likely you executed SQL more than once, so table data was already cached. SY. ... |
|||
:
Нравится:
Не нравится:
|
|||
19.03.2006, 16:43 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
SY good since if reflects (don't know how accurate though) scalability issue I think one would better say: analytics is a tradeoff - they trade memory for speed SY you should have at least as many "disk" as it takes to read the table itself no i should not - given i had buffer cache large enought you do realize that Код: plaintext 1. 2. 3. 4. 5. 6.
is a conventional insert? It will already cache blocks for us. consider: Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26.
and the tkprof Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13.
zero PIO - for you see. Data was already cached for us by insert. btw - in 10GR2 you don't need to bounce as there is alter system flush buffer_cache . ... |
|||
:
Нравится:
Не нравится:
|
|||
20.03.2006, 02:40 |
|
Периоды, объединение
|
|||
---|---|---|---|
#18+
Q u a d r ono i should not - given i had buffer cache large enought you do realize that It will already cache blocks for us. I do realize it. And that was exactly what I talking about. In real test there will not be a preceding insert, select or any other case that caches table. And taking into consideration 60,000,000 rows and multiuser system I would not count on 0 "disk". SY. ... |
|||
:
Нравится:
Не нравится:
|
|||
20.03.2006, 17:18 |
|
|
start [/forum/topic.php?fid=52&fpage=69&tid=1882192]: |
0ms |
get settings: |
11ms |
get forum list: |
14ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
29ms |
get topic data: |
13ms |
get forum data: |
3ms |
get page messages: |
138ms |
get tp. blocked users: |
2ms |
others: | 249ms |
total: | 467ms |
0 / 0 |