Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Latin America Tour 2019 - slow data and sql processing

60 views

Published on

Well done! You've come up with the killer idea for 2020. You've got the best UI design anyone has ever seen! Your modern application ticks all the boxes — serverless, functional, Kubernetes, microservices, API-based, the list goes on. It runs on every OS and every type of device. But unfortunately, all of this counts for absolutely NOTHING if your data access is slow or buggy. But an Autonomous database will fix all that right? Only if you understand the fundamentals of how SQL is processed by the database. For novice developers, SQL can be hard to understand and sometimes totally hidden from view under an ORM. Let's peel back the covers to show how SQL is processed, how to avoid getting hacked, and how to get data back to your application in a snappy fashion.

Published in: Technology
  • Unlock The Universe & Get Answers You Seek Today In Your FREE Tarot Reading. DO THIS FIRST... To get the most out of your tarot reading, I first need you to focus your intention - this concentrates the energy on the universe to answer the questions that you most desire the answers for. Take 10 seconds to think of your #1 single biggest CHALLENGE right now. (Yes, stop for 10 seconds, close your eyes, and focus your energy on ONE key problem) Ready? Okay, let's proceed. ➢➢➢ https://t.cn/A627c6mK
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Latin America Tour 2019 - slow data and sql processing

  1. 1. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. bienvenido
  2. 2. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Lo siento, no hablo español :-(
  3. 3. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. But I will do my best to help Pero haré todo lo posible para ayudar
  4. 4. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Connor McDonald
  5. 5. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 6
  6. 6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 7
  7. 7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 8
  8. 8. Me connor-mcdonald.com https://linktr.ee/connor
  9. 9. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 10https://asktom.oracle.com
  10. 10. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. https://asktom.oracle.com/officehours
  11. 11. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 11
  12. 12. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 12
  13. 13. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. no matter how many layers ... 13 no importa cuántas capas
  14. 14. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. somewhere you are doing ... 14 XXXalgun lado tú lo estás haciendo
  15. 15. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. ... data access with SQL 15 acceso a datos con SQL
  16. 16. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL is like any language 13 SQL es como ninguna idioma
  17. 17. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. compile it 14 compilarlo
  18. 18. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. compile it 14 on the fly sobre la marcha
  19. 19. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. run it 15 ejecutarlo
  20. 20. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. get | store results 16 obtener | almacenar resultados
  21. 21. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. for successful applications... 17 para aplicaciones exitosas
  22. 22. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. compile it ... fast 18 rápido
  23. 23. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. run it ... fast 19 rápido
  24. 24. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. get | store results ... fast 20 rápido
  25. 25. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. that is all! 21 ¡Eso es!
  26. 26. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. what everyone talks about 22 de lo que todos hablan
  27. 27. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. compile execute store/fetch results 23
  28. 28. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. this session 24 esta sesión
  29. 29. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. compile execute store/fetch results 25
  30. 30. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. before we begin ... antes de que comencemos
  31. 31. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | connor_mc_dconnor mcdonald.com controversy 31 controversia
  32. 32. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. here is the problem... 32 aqui esta el problema
  33. 33. 33
  34. 34. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. a small digression una pequeña digresión
  35. 35. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. a little bit of history on servers ... un poco de historia en los servidores
  36. 36. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. (not too) long ago no hace mucho
  37. 37. Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
  38. 38. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. FSB = "front side bus" 38
  39. 39. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. any access to ... anything cualquier acceso a ... cualquier cosa
  40. 40. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. CPU capped
  41. 41. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. hypertransport
  42. 42. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. memory access direct from CPU 44 acceso a memoria directo desde la CPU
  43. 43. ~2007
  44. 44. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. "why do I care?" "¿Porqué me importa?"
  45. 45. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. you can't blame the server (anymore) 48 ya no puedes culpar al servidor
  46. 46. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. if you can't get that performance ... si no puedes obtener ese rendimiento
  47. 47. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. ... it is our fault está nuestro culpa
  48. 48. 52
  49. 49. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. good code buen código
  50. 50. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. so what's holding us back ? ¿qué nos está frenando?
  51. 51. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. It all comes down to... Todo se reduce a
  52. 52. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. too much work or ... demasiado trabajo
  53. 53. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. ... not being able to do work 58 no poder hacer el trabajo
  54. 54. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. PART #1 56 compiling SQL
  55. 55. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. ... how to avoid work when processing SQL cómo evitar el trabajo excesivo al procesar SQL
  56. 56. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. terminology 61
  57. 57. cursors
  58. 58. cursors declare cursor C(p number) is select * from DEPT where DEPTNO = p; begin for rec in C loop … end loop; end; select * from EMPLOYEE where EMPNO > 1234; delete from MY_TABLE; drop table MY_TABLE; begin MY_PROCEDURE(1,2,3); end;
  59. 59. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. all of them ! todos ellos !
  60. 60. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 3 phases
  61. 61. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. open process close give me some memory do some stuff using that memory, maybe access other memory here's your memory back 66 Dame un poco de memoria usa la memoria devolver la memoria
  62. 62. memory access = controlled access acceso a memoria = acceso controlado
  63. 63. a quick primer on (database) memory una cartilla rápida en memoria
  64. 64. 66 metaphor
  65. 65. 67
  66. 66. 71 limited resource lots of people want it concurrent access causes problems it's a complex system recurso limitado mucha gente lo quiere el acceso concurrente causa problemas es un systema complejo
  67. 67. 73 same with memory lo mismo con la memoria
  68. 68. SGA
  69. 69. SGA protected by
  70. 70. SGA protected by 1) get latch
  71. 71. SGA protected by 1) get latch
  72. 72. SGA protected by 2) access memory
  73. 73. SGA protected by 2) access memory
  74. 74. SGA protected by 3) release latch
  75. 75. SGA protected by 3) release latch
  76. 76. latch contention
  77. 77. SGA protected by someone must wait ... alguien debe esperar
  78. 78. active wait activo espere
  79. 79. spinning 89 hilado
  80. 80. spinning can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ?can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? can I have the latch ? 90
  81. 81. latch contention....
  82. 82. hurts CPU... 94 duele la CPU
  83. 83. hurts concurrency duele la concurrencia
  84. 84. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. YOU
  85. 85. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. GET
  86. 86. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. NOTHING
  87. 87. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. DONEno logras nada
  88. 88. "When are we talking about SQL?" "¿Cuándo estamos hablando de SQL?
  89. 89. to run a SQL statement para ejecutar una declaración SQ
  90. 90. Syntax Validity Optimization Rowsourcing Execution (Fetch) 107
  91. 91. Syntax Validity Optimization Rowsourcing Execution (Fetch) SQL> select * 2 frmo emp; frmo emp * ERROR at line 2: ORA-00923: FROM keyword not found where expected 108
  92. 92. Syntax Validity Optimization Rowsourcing Execution (Fetch) SQL> select empnoo 2 from emp; select empnoo * ERROR at line 1: ORA-00904: invalid column name
  93. 93. Syntax Validity Optimization Rowsourcing Execution (Fetch) PLAN ------------------------------------- SELECT STATEMENT TABLE ACCESS BY INDEX ROWID EMP INDEX RANGE SCAN EMP_PK
  94. 94. EMP_PK EMP Syntax Validity Optimization Rowsourcing Execution (Fetch)
  95. 95. Syntax Validity Optimization Rowsourcing Execution (Fetch) 112
  96. 96. Syntax Validity Optimization Rowsourcing Execution (Fetch)
  97. 97. lots of preliminary steps muchos pasos preliminares
  98. 98. parsing 103 "compile"
  99. 99. lots of memory access 116 mucha memoria de acceso
  100. 100. lots of latching ! 117
  101. 101. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. impossible to avoid ? imposible de evitar?
  102. 102. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. library cache
  103. 103. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. previously executed statements 120 declaraciones ejecutadas previamente
  104. 104. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. parse statement select * from emp where empno = 123
  105. 105. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. parse statement already in library cache ? select * from emp where empno = 123
  106. 106. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. parse statement already in library cache ? select * from emp where empno = 123 syntactically, semantics OK
  107. 107. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. parse statement already in library cache ? reuse optimizer info select * from emp where empno = 123 syntactically, semantics OK
  108. 108. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. parse statement already in library cache ? reuse optimizer info reuse row source info select * from emp where empno = 123 syntactically, semantics OK
  109. 109. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. select surname, firstname from emp where empno = 123 select * from dept where deptno = 4567 select * from customer where locality = 17 select prno from property where reference = 'X123G' select * from dept where deptno = 23 select surname, firstname from emp where empno = 123 select * from customer where locality = 256 select * from organisation where officer = 'OFF876' select surname, firstname from emp where empno = 7632 select * from dept where deptno = 4567 select offender from crimes where crno = 247462 Two full parses avoided library cache
  110. 110. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. select surname, firstname from emp where empno = 123 select * from dept where dname = 'SALES' probability of reuse low ? probabilidad de reutilización baja?
  111. 111. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. some queries are “nearly the same” 128 select surname, firstname from emp where empno = 123 select surname, firstname from emp where empno = 456 algunas consultas son "casi iguales"
  112. 112. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. binding
  113. 113. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. binding parse this... select surname, firstname from emp where empno = ?
  114. 114. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. binding parse this... now run it with ? = 123 now run it with ? = 456 select surname, firstname from emp where empno = ?
  115. 115. select surname, firstname from emp where empno = ? select * from dept where deptno = ? select * from customer where locality = ? select prno from property where reference = ? select * from dept where deptno = ? select surname, firstname from emp where empno = ? select * from customer where locality = ? select * from organisation where officer = ? select surname, firstname from emp where empno = ? select * from dept where deptno = ? select offender from crimes where crno = ? Five full parses avoided library cache
  116. 116. demo
  117. 117. demo ParseDemo ParseDemoBind
  118. 118. "performance still looks ok" "el rendimiento todavía se ve bien"
  119. 119. let us use real queries hagámoslo real
  120. 120. let's make it real ParseDemo2 nn ParseDemo2Bind nn
  121. 121. much more serious mucho Más grave
  122. 122. building SQL by concatenation construir SQL por concatenación
  123. 123. you'll get hacked
  124. 124. select ename from emp where empno = 6543
  125. 125. select ename from emp where empno = 6543 select ename from emp where empno = 6543 and 1=0 union all select table_name from all_tables where table_name like '%SECURITY%'
  126. 126. select ename from emp where empno = 6543 select ename from emp where empno = 6543 and 1=0 union all select table_name from all_tables where table_name like '%SECURITY%' select ename from emp where empno = 6543 and 1=0 union all select username from app_security where ...
  127. 127. 144
  128. 128. you'll get hacked ... ... really easily! muy fácil!
  129. 129. #1 hacking app .....
  130. 130. #1 hacking app ..... Google
  131. 131. it takes 5 minutes to hack you se necesita 5 minutos
  132. 132. for fast, secure SQL ... para rápido seguro SQL
  133. 133. ... always bind user input siempre vincula la entrada del usuario
  134. 134. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. while we are talking about binding mientras hablamos de encuadernación
  135. 135. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. parse statement already in library cache ? reuse optimizer info reuse row source info select * from emp where empno = 123 syntactically, semantics OK Yes! Yes! ??? ???
  136. 136. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. still some parsing to do 156
  137. 137. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Syntax Validity Optimization Rowsourcing Execution (Fetch) Hard Parse Soft Parse foundnot found in lib cache
  138. 138. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. scott@mydb> select * 2 from EMP 3 where EMPNO = :b1 mike@mydb> select * 2 from EMP 3 where EMPNO = :b1
  139. 139. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. scott@mydb> select * 2 from EMP 3 where EMPNO = :b1 anna@mydb> select * 2 from EMP 3 where EMPNO = :b1 SQL> desc anna.emp Name Null? Type ----------------- -------- ------------ EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9)
  140. 140. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. (even soft) parsing = memory access = latching
  141. 141. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. can we do better ? podemos hacerlo mejor?
  142. 142. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. recall recuerda
  143. 143. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. open process close give me some memory do some stuff using that memory, maybe access other memory here's your memory back 163 Dame un poco de memoria usa la memoria devolver la memoria
  144. 144. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. your SQL is always shareable library cache select * from emp tu SQL siempre se puede compartir
  145. 145. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. your cursor points to it library cache select * from emp cursor 165
  146. 146. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. close cursor = lose pointer library cache select * from emp cursor cercano = perder puntero cursor
  147. 147. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. next time we parse soft parse la próxima vez
  148. 148. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. impossible to avoid ? 168 imposible de evitar?
  149. 149. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. what if we don't close the cursor Y si nos no lo hagas cierra el cursor
  150. 150. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. library cache select * from emp cursor 1 select * from dept cursor 2 select * from emp where ... cursor 3
  151. 151. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. library cache select * from emp cursor 1 select * from dept cursor 2 select * from emp where ... cursor 3 pstmt_all_emp = con.prepareStatement("select * from emp");
  152. 152. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. emplist(String[] args) { if "first time" { else "reset the pointer, re-execute" } library cache select * from emp cursor 1 select * from dept cursor 2 select * from emp where ... cursor 3 pstmt_all_emp = con.prepareStatement("select * from emp");
  153. 153. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. don’t close the cursor no cierres el cursor
  154. 154. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. hang on to the memory mantener la memoria
  155. 155. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. remember what cursors we’ve used recuerda qué cursores hemos usado
  156. 156. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. reuse whenever possible reutilizar siempre que sea posible
  157. 157. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. don’t exhaust memory no agotar la memoria
  158. 158. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. don’t allow invalid cursor reuse no permitir la reutilización inválida del cursor
  159. 159. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. sounds complicated ... Suena complicado
  160. 160. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. a free solution exists gratis la solución
  161. 161. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. plsql
  162. 162. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. create procedure MY_PROC is begin select empno, ename, ... into … from emp where empno = my_plsql_variable ... end;
  163. 163. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. static SQL in stored PLSQL automatically uses bind variables hold’s cursors open (even if you close)
  164. 164. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. better cursor caching mejor almacenamiento en caché del cursor
  165. 165. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. procedure MY_PROC is begin select * into … from dept where … end; select * from dept …
  166. 166. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. procedure MY_PROC is cursor c_emp is select * from emp; begin open c_emp; fetch c_emp into …; close c_emp; end; select * from emp procedure MY_PROC is begin select * into … from dept where … end; select * from dept …
  167. 167. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. plsql in the database
  168. 168. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 171 PART #2 get | store results
  169. 169. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 172
  170. 170. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. start with reading data 173 Empezar con leyendo datos
  171. 171. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. querying data
  172. 172. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. data is stored in blocks | pages los datos se almacenan en bloques | paginas
  173. 173. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. to read data, you read blocks... para leer datos, lees bloques
  174. 174. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL> select * 2 from EMP 3 where ... /u01/my_data1.dat memory
  175. 175. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. but (database) memory access is complex 195 pero el acceso a la memoria es complejo
  176. 176. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL> select * 2 from EMP 3 where … SQL> update EMP 2 set … 3 where … SQL> select * 2 from EMP 3 where … SQL> insert into 2 EMP 3 values (…) SQL> select * 2 from CUSTOMER 3 / SQL> select max(EMP) 2 from DEPT SQL> delete 2 from DEPT 3 /
  177. 177. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. we have to latch !
  178. 178. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. • Get latch • Search along list of blocks in memory • Read block • Extract row of interest • Release latch • Give row back to client "fetch a row" 198 Obtener el pestillo Buscar en la lista de bloques en la memoria Leer bloquear Extraer fila de interés Liberar el pestillo Devolver la fila al cliente
  179. 179. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. lots of rows muchas filas
  180. 180. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. lots of latching
  181. 181. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. typical program
  182. 182. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. rs = stmt.executeQuery("..."); while(rs.next()) { v1 = rs.getInt(1); v2 = rs.getString(2); ... } 202
  183. 183. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. rs = stmt.executeQuery("..."); while(rs.next()) { v1 = rs.getInt(1); v2 = rs.getString(2); ... } • Get latch • Walk along list • Get block • Extract single row • Release latch • Give row back to client • Get latch (again) • Walk along list (again) • Get block (again) • Extract single row • Release latch (again) • Give row back to client (again) Row #1 Row #2 • Get latch (again) • Walk along list (again) • Get block (again) • Extract single row • Release latch (again) • Give row back to client (again) Row #3 203
  184. 184. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. a better strategy.... “pinning” una mejor estrategia
  185. 185. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. "fetch a row"
  186. 186. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. "fetch a row" “and .. I may need many rows from this block” Puedo necesitar muchos filas de esto bloquear"
  187. 187. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. "fetch a row" •Get latch •Walk along list •Get block •Pin the block •Release latch •Give row 1 back to client •Give row 2 back to client •Give row 3 back to client … •Give row n to client •Get latch •Walk along list •Remove my pin on the block •Release latch “and .. I may need many rows from this block”
  188. 188. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. how do you say ? “I may want many rows” Cómo se dice ? "Puedo querer muchas filas"
  189. 189. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. responsibility of the client responsabilidad del cliente
  190. 190. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 190
  191. 191. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 190
  192. 192. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 190
  193. 193. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 190
  194. 194. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 190 FetchDemo nn
  195. 195. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. focus on blocks 191
  196. 196. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. focus on roundtrips 192
  197. 197. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. nothing in life is free ! 192 nada en la vida es gratis
  198. 198. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. all that data goes somewhere 220 todos esos datos van algun lado
  199. 199. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL> declare . . . 9 begin 10 open c; 11 loop 12 fetch c 13 into r; 14 exit when c%notfound; . . . 19 / Elapsed: 00:01:11.72
  200. 200. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL> declare . . . 9 begin 10 open c; 11 12 fetch c 13 bulk collect 14 into r; 15 . . . 19 / Elapsed: 00:00:08.93
  201. 201. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL> select * from v$mystats 2 where name like '%pga%' 3 / NAME VALUE ------------------------------ ---------- session pga memory 501534672 session pga memory max 501534672
  202. 202. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 500m of memory !
  203. 203. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. pin rows on a block (8k) 225
  204. 204. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL> declare . . . 9 begin 10 open c; 11 loop 12 fetch c 13 bulk collect 14 into r limit 100; 15 exit when c%notfound; . . . 19 / Elapsed: 00:00:08.17 NAME VALUE ------------------------------ ---------- session pga memory 625912 session pga memory max 625912
  205. 205. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. SQL> declare . . . 9 begin 10 for i in c loop 12 ... 16 end loop; 17 end; 18 / Elapsed: 00:00:08.21
  206. 206. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. PART #2(a) storing data
  207. 207. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. the same rules apply 205 se aplican las mismas reglas
  208. 208. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. think blocks not rows 206 when appropriate pensar bloques no filas
  209. 209. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. demo 208 InsertDemo3 InsertDemo4 nn
  210. 210. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. summary
  211. 211. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. avoid parsing costs for high frequency SQL evitar costos de análisis para SQL de alta frecuencia
  212. 212. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. use binding and don't get hacked ! ¡usa el enlace y no te hackeen!
  213. 213. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. PLSQL in the database is golden PLSQL en la base de datos es dorado
  214. 214. Thank you! connor-mcdonald.com https://linktr.ee/connor Gracias!

×