YouTube2Text

Larry Ellison was Right (kinda)! TypeScript Stored Procedures for the Modern Age (James Cowling) — Transcript

by CMU Database Group · 12,155 words · 1,705 segments · language en · Watch on YouTube

Full transcript

  1. 0:05[Music]
  2. 0:06Nationwide
  3. 0:10hat sequel or death yo son what are you
  4. 0:13going to choose yo check it this seminar
  5. 0:17is filmed at Carnegie melon
  6. 0:19University thanks a lot
  7. 0:23Google all right everyone it's a new
  8. 0:25semester uh we're super excited today to
  9. 0:28to kick off the new seminar series on
  10. 0:29SQL or death and the goal of this is for
  11. 0:32to discuss attempts to replace SQL uh
  12. 0:36and then attempts to make SQL better
  13. 0:37through different czers so today we're
  14. 0:40kicking off with attempt to replace SQL
  15. 0:42uh we're super excited today to have
  16. 0:44James calling he is the co-founder of
  17. 0:47convex which is the the system or the
  18. 0:49framework he's talk about today uh prior
  19. 0:52to that he was in charge of all
  20. 0:54databases at Dropbox for several years
  21. 0:56and then prior to that he got his PhD in
  22. 0:59computer science science uh working with
  23. 1:02with Bara Li call so if you don't know
  24. 1:03James let me put it this way there's
  25. 1:05Brandon Greg Steve Irwin James calling
  26. 1:09those are the three most important
  27. 1:10people that made the the biggest
  28. 1:12contributions uh from Australia to
  29. 1:14computer systems so that's why it's a
  30. 1:16big deal for us to have James today
  31. 1:17James the floor is yours go for it thank
  32. 1:20you Andy if you have any questions for
  33. 1:21James interrupt as you go along as he
  34. 1:23goes along that way he's not talking to
  35. 1:24himself for an hour excent please jump
  36. 1:26in and if I don't um if I don't notice
  37. 1:28your chat pop up because I'm like
  38. 1:29looking forwards um just unmute and yell
  39. 1:32out um I won I won't mind um so cool hi
  40. 1:35everyone and today I'm going to talk
  41. 1:36about this idea called database stored
  42. 1:39procedures and this is the ability to
  43. 1:40run real code within a transaction um
  44. 1:44I'm going to argue that these are
  45. 1:45actually a pretty good idea even though
  46. 1:47a lot of people hate them uh and I think
  47. 1:49that we should revisit these but not in
  48. 1:51some weird esoteric language but just in
  49. 1:53typescript right um so Andy gave me the
  50. 1:56bio gave my bio already um my
  51. 1:58backgrounds in in distributed databases
  52. 2:01um design the storage system at Dropbox
  53. 2:03um which stores multiple exobytes of
  54. 2:06data and and design the database which
  55. 2:08runs I don't know several million
  56. 2:09transactions per second um but um not
  57. 2:12just um a database Builder a lot of my
  58. 2:16my time has spent managing teams that
  59. 2:18have The Misfortune of using databases
  60. 2:20um and I have a company now called
  61. 2:21convex um all our customers are
  62. 2:23application developers have to build on
  63. 2:25top of databases and so I want to really
  64. 2:26talk today about addressing some um
  65. 2:30reasons why databases aren't meeting the
  66. 2:31needs of application developers right so
  67. 2:34there's a talk about databases hopefully
  68. 2:35with this audience I don't need to
  69. 2:36explain this but there's this annoying
  70. 2:38um Trend right now to conflate these
  71. 2:41terms SQL database with rdbms right
  72. 2:44relational database so my SQL post these
  73. 2:46are relational databases they have
  74. 2:48structured data and a storage engine and
  75. 2:50transactions and some way of quering
  76. 2:51them and just so happens that way of
  77. 2:53quering them is is SQL um but they're
  78. 2:57great databases otherwise right and so
  79. 2:59this is not an argument against um
  80. 3:01relational databases this is not a pro
  81. 3:03nosql talk in the in the sense that no
  82. 3:06SQL means no relational databases this
  83. 3:09is just an argument that we're argu
  84. 3:11we're interacting with our databases I
  85. 3:13think in the wrong way so um I'm going
  86. 3:16to start off with some Basics and we'll
  87. 3:18get more advanced as we go so you know
  88. 3:20the real core building block of most
  89. 3:21databases is the transaction right this
  90. 3:22is the ability to execute stuff
  91. 3:24atomically it's the a in acid it means
  92. 3:27you can do multiple things uh and during
  93. 3:29the transaction you don't have to think
  94. 3:31about the world changing underneath you
  95. 3:33right so um databases without
  96. 3:34transactions is like you know writing
  97. 3:36multi-threaded programs with shared
  98. 3:38memory and no locks right they don't
  99. 3:40really work so a transaction reads some
  100. 3:42stuff writes some stuff and makes some
  101. 3:44decisions in the process so let's start
  102. 3:47with um what I think the most basic
  103. 3:50transaction kind of everyone knows this
  104. 3:52is kind the the classic transaction
  105. 3:53people talk about in textbooks it's the
  106. 3:55bank transfer example right so this is
  107. 3:57an example where you have a sender and a
  108. 3:59recipient and you want to move some
  109. 4:01money from the senders account to the
  110. 4:03recipient's account um provided the
  111. 4:06sufficient funds and my challenge to you
  112. 4:10is to write this query in SQL uh write
  113. 4:13this query in actual SQL in in in pure
  114. 4:15sequel not in another programming
  115. 4:17language talking to SQL go write this
  116. 4:19query in real SQL um and if you're
  117. 4:22watching this on on on video you can
  118. 4:24pause this and go and try and do this
  119. 4:25challenge right cuz it's not so easy cuz
  120. 4:29you're going to want use an if statement
  121. 4:30in there and you can't do an if
  122. 4:32statement in in pure SQL so you're
  123. 4:35probably going to look up various SQL
  124. 4:37extensions but you can do this in SQL
  125. 4:39right so here's an answer in um my SQL
  126. 4:43at least uh this is a this is a um I
  127. 4:45don't think this works in postgress
  128. 4:46because I don't think you can do two
  129. 4:48table updates at once in postgress but
  130. 4:50you can in my SQL so this is an example
  131. 4:52of you know a short but relatively
  132. 4:54convoluted join that will do this thing
  133. 4:57and here's an answer how you could do
  134. 5:00this in postgress and I believe this
  135. 5:01works in postgress there's a there's a
  136. 5:03case statement in SQL there's no if
  137. 5:05statement um this looks kind of simple
  138. 5:09but then if you stare at it a bit longer
  139. 5:10it's not that simple and I don't think
  140. 5:12you would have just written this out by
  141. 5:13yourself if I just asked you and gave
  142. 5:15you a minute to do so um and this is a
  143. 5:18really simple example this is a this is
  144. 5:19a very simple bank transfer a real life
  145. 5:22bank transfer involves all sorts of
  146. 5:24checks and logging and fraud detection
  147. 5:26right and so You' never be able to write
  148. 5:28this in SQL and you're probably going to
  149. 5:29say this is stupid James like why are
  150. 5:31you asking me to implement business
  151. 5:33logic in a query language this is not
  152. 5:36how people use SQL and I would say
  153. 5:38exactly right SQL is not a language for
  154. 5:40business logic applications are made up
  155. 5:42of business logic and SQL is a query
  156. 5:45language um so the reason that was hard
  157. 5:48is because you want to use control
  158. 5:49structures what you want to use a
  159. 5:51procedural language and SQL is a
  160. 5:54declarative query language right and I
  161. 5:57gave you the most simple example in the
  162. 5:58world of a bank transfer most things are
  163. 6:00much harder than this right and of
  164. 6:02course no one would ever try to do this
  165. 6:05in SQL and no one would assume that
  166. 6:07people do this in SQL except um a few
  167. 6:10database researchers right so this is
  168. 6:12this is a this is a you know a bit of an
  169. 6:15opus this is a classic paper by Andy
  170. 6:17paver you might know him um and there
  171. 6:19there's there's two points made in this
  172. 6:21paper right uh you know it's a bit of an
  173. 6:23irreverent paper obviously but one is
  174. 6:25that is that the database research
  175. 6:27assumes serializability and also
  176. 6:29database uh research assumes that people
  177. 6:32use stored procedures run everything in
  178. 6:34a single Atomic block of of SQL code um
  179. 6:36but in the real world no one actually
  180. 6:38does this right so what do people do in
  181. 6:42the real world so they've got kind of
  182. 6:44two options in the real world one and
  183. 6:48these are both real options by the way
  184. 6:50right one is the one you'd probably
  185. 6:51expect you write API services in some
  186. 6:54other language on the server that talks
  187. 6:56to the database or two which is a very
  188. 6:59popular and very common model is to just
  189. 7:01give up on transactions and leak your
  190. 7:03entire database to the
  191. 7:05client so I'll talk about the the server
  192. 7:08side API stuff first this is probably
  193. 7:10how you think a database normally works
  194. 7:12or how you normally interact with
  195. 7:13databases if you're at a larger company
  196. 7:15this is how you would interact with the
  197. 7:16database you have a front end and a
  198. 7:18backend and the front end can't talk to
  199. 7:19the database right the front end talks
  200. 7:21to an API service and that API service
  201. 7:24talks to the database and runs all the
  202. 7:25business logic right so there's this
  203. 7:26pretty um hard dividing line between the
  204. 7:29front end and the back end here and only
  205. 7:31the back end can talk to the DB and
  206. 7:34here's an example of how you would
  207. 7:36implement this bank transfer in Python
  208. 7:39um it's probably what you think about
  209. 7:40when you think of a SQL transaction it's
  210. 7:42not that complicated I mean you have
  211. 7:44select for update in here which is a
  212. 7:46little bit of a gotcha you'd have to use
  213. 7:48because you're probably running this in
  214. 7:49read committed um but the really
  215. 7:51important line here is you have an if
  216. 7:53sender balance is less than amount right
  217. 7:54you get to do um an if
  218. 7:57statement um so this runs into a
  219. 7:59transaction and the transaction stays
  220. 8:01open for the duration of that with con.
  221. 8:03cursor block um otherwise you're
  222. 8:06happy so this seems like the normal way
  223. 8:09of writing database um code what's wrong
  224. 8:13with it um so it's easy to do the wrong
  225. 8:16thing it's quite hard to test SQL code
  226. 8:18right because it's it's it's a text
  227. 8:20based language with with with weak weak
  228. 8:23type safety um small typos can easily
  229. 8:26destroy a company I've seen people make
  230. 8:28small typos in SQL and Destroy databases
  231. 8:30before in practice um it's really easy
  232. 8:33to blow away your whole company it's
  233. 8:35really easy to leave at a wear clause
  234. 8:37and typically in practice no one's
  235. 8:39really writing SQL queries like this in
  236. 8:41any larger company you have all these
  237. 8:43layers of abstraction and ORS which kind
  238. 8:45of hide the database calls to protect
  239. 8:48you from
  240. 8:49them it's very easy to leak uncommitted
  241. 8:52State this is a this is a big problem
  242. 8:54that you might not think about right
  243. 8:55when you're um in having pretty deep
  244. 8:57call Stacks so you call a function which
  245. 8:59which calls a function which calls a
  246. 9:00function which talks to a database it's
  247. 9:03very easy to externalize uncommitted
  248. 9:05database state so it's very easy to go
  249. 9:07and send an email to a customer before
  250. 9:10the transaction is committed and this
  251. 9:11happens all the time and people get you
  252. 9:12know welcome to you know whatever emails
  253. 9:15and they haven't actually been added to
  254. 9:16the database
  255. 9:18yet also it can have long execution
  256. 9:21times which block database resources so
  257. 9:23there's latency between the application
  258. 9:26server and the database um often times
  259. 9:28you be keeping locks open for the
  260. 9:30duration of this transaction is very
  261. 9:32easy to add arbitrary compute in there
  262. 9:34and take a long time and so you've got
  263. 9:36snapshots or locks around or undo logs
  264. 9:38or vacuuming that's not happening and as
  265. 9:41a result typically you have to ask
  266. 9:43someone to write this API for you if
  267. 9:45you're an application developer because
  268. 9:46it's quite easy to break a database and
  269. 9:49see this is the real key problem here I
  270. 9:50think and this is not like a trivial
  271. 9:52problem this is a real real problem
  272. 9:54that's affecting the industry right it's
  273. 9:56this front end and backend divide so
  274. 9:59typically there's a team that writes the
  275. 10:00applications on the database like the
  276. 10:02the team that writes the the app code
  277. 10:04the front end and a team that writes
  278. 10:05apis to talk to the database and every
  279. 10:08company has a bunch of front-end
  280. 10:10developers that are annoyed because they
  281. 10:11can't move fast because it takes too
  282. 10:13long to convince someone to add apis
  283. 10:15right and so you end up with stuff like
  284. 10:17graph qwl but even with graph qwl you
  285. 10:19need a team there to write resolvers for
  286. 10:20you right there's no kind of Silver
  287. 10:22Bullet
  288. 10:24there so all these things culminate in
  289. 10:27this model being inconvenient to use and
  290. 10:29you you don't have to trust me on this
  291. 10:30because developers have tried to move
  292. 10:31away from this model at least twice I
  293. 10:33can think of probably more times but one
  294. 10:36was the nosql movement which despite all
  295. 10:38the talk about web scale at the time was
  296. 10:41really about developer ergonomics right
  297. 10:43so you had this new wave of this Web 2.0
  298. 10:45app developers we building interactive
  299. 10:47websites all of a sudden and they're
  300. 10:49writing the full stack now and they just
  301. 10:51want to stick some Json in a table and
  302. 10:53comes along and they give you the
  303. 10:56ability to do that and so you if you're
  304. 10:58you know on the youngest side you might
  305. 11:00not remember this but if you've been
  306. 11:01around for a while you would remember a
  307. 11:04time when was was real hot and no
  308. 11:06one was talking about postgress right um
  309. 11:10so everyone kind of moved to this nosql
  310. 11:12model and I'm actually a fan of of
  311. 11:15and this modern Incarnation but these
  312. 11:17databases these nosql databases didn't
  313. 11:18just get rid of SQL they got rid of
  314. 11:20transactions and relations and large
  315. 11:22cases type safety right and then this
  316. 11:24happened right then everyone decided
  317. 11:26they didn't like no sequel right if
  318. 11:29became all of a sudden was really uncool
  319. 11:31to use post and then it became uncool to
  320. 11:33use no SQL databases right because
  321. 11:35people wanted transactions and relations
  322. 11:37and schemers and only after this point
  323. 11:40did we enter this new modern era of like
  324. 11:42postgress is cool back then there was
  325. 11:45like web developers weren't talking
  326. 11:46excitedly about postgress as if
  327. 11:48postgress was this exciting
  328. 11:50thing so people went back to the old way
  329. 11:54oh have API servers talking to databases
  330. 11:56but not for long cuz then the serverless
  331. 11:59movement came along and this is a
  332. 12:00movement that's that's happening right
  333. 12:02now we're in this movement and and it's
  334. 12:04I I don't think it's going away and I
  335. 12:05hope that it doesn't go away um this is
  336. 12:08a movement driven by the needs of app
  337. 12:10developers or what I would describe as
  338. 12:12the new serverless way of building stuff
  339. 12:14so how are modern apps developed they're
  340. 12:17started by front-end developers that's
  341. 12:19app they call themselves full stack app
  342. 12:21developers that's who starts the company
  343. 12:23these days right the apps are typically
  344. 12:25web apps and they're typically written
  345. 12:26in typescript and more and more business
  346. 12:29logic is moving to client code right so
  347. 12:32a lot of these apps are getting written
  348. 12:33in typescript on clients in a repo in
  349. 12:37JavaScript typescript repo that's
  350. 12:39getting deployed directly to hosted
  351. 12:40backend services like Vel or netfi or um
  352. 12:43cloudflare Etc so we had this old
  353. 12:46way and we've moved to this new way
  354. 12:49right and this new way I think Pioneer
  355. 12:51by Firebase but I'm I'm not sure who you
  356. 12:53know who who really drove I think
  357. 12:55Firebase really became the popular
  358. 12:57proponents of this model right and has a
  359. 12:59lot in common with the nosql movement um
  360. 13:01but people are doing this with postgress
  361. 13:02now right it's where you expose the
  362. 13:04database directly to code running on
  363. 13:06client
  364. 13:08applications seems a bit strange but
  365. 13:10it's a natural shift towards allowing
  366. 13:12developers to write their own code in
  367. 13:13typescript and be able to iterate as
  368. 13:15fast as they want on the app code and
  369. 13:17deploy um their backend code at the same
  370. 13:20time as they deploying their front end
  371. 13:23and in many ways this is a rejection of
  372. 13:25this old front end backend divide and in
  373. 13:28respect I think it's a good thing thing
  374. 13:30right I think the lack of a divide is a
  375. 13:33good thing I don't necessar think this
  376. 13:34model is a good thing right so what is
  377. 13:37wrong with just exposing the database to
  378. 13:38the client well you know you had all
  379. 13:40these nice attributes of API services
  380. 13:42like abstracting a database away right
  381. 13:44but now we're leaking our data model to
  382. 13:46the client we've got no abstraction now
  383. 13:47we're just letting the client code see
  384. 13:50our implementation inside our database
  385. 13:52and we need to have now roow level
  386. 13:54security you need to have figure out
  387. 13:55ways of mapping authorization domains to
  388. 13:59rows in tables which is very complicated
  389. 14:02it's it's it's fine on a demo app on a
  390. 14:04preview app when an application gets
  391. 14:06large it's quite hard to express all the
  392. 14:09abstraction and and authorization rules
  393. 14:11in in in in a couple of RLS um
  394. 14:14configurations it leads to thick clients
  395. 14:17and also it leads to inconsistency
  396. 14:19because we've largely given up on
  397. 14:20transactions in this model right you
  398. 14:22can't have a client on a website start a
  399. 14:24transaction and then just go away
  400. 14:27right you trust the client to keep those
  401. 14:30resources
  402. 14:31open um so what do we do if we want to
  403. 14:35run a real Transaction what if you want
  404. 14:36to do a bank transfer well I don't think
  405. 14:39you can really I mean um you have to go
  406. 14:42back to the API model you have to go
  407. 14:44back to having some code some on a
  408. 14:46trusted demon running next to your
  409. 14:48database which is running the running
  410. 14:49the bank transaction for you or you
  411. 14:51could use stored procedures which you'll
  412. 14:52get to but you can't have a client
  413. 14:55starting a transaction and then just
  414. 14:57going away so in some respects this
  415. 14:59movement towards this new model is a
  416. 15:01movement away from transactions which is
  417. 15:03which is not a great thing right um so I
  418. 15:07would argue that the people what the
  419. 15:09people want is functions right they want
  420. 15:12the ability to express their business
  421. 15:14logic as actual functions and and it
  422. 15:17wouldn't it be great if we could just
  423. 15:19send that business logic directly to the
  424. 15:21database and have it run in a
  425. 15:25transaction so this brings us to my boy
  426. 15:27Larry right the o G databas CEO founder
  427. 15:30of Oracle owner of big boats and and
  428. 15:32other things third in the world yeah and
  429. 15:36and newly married newly married um yeah
  430. 15:40second richest person in the world Andy
  431. 15:41you said third he's third third rich
  432. 15:43person in the world he bounces back
  433. 15:44between second and third he's third
  434. 15:46right now so people in the database
  435. 15:47world love to hate on Larry right
  436. 15:49perhaps they're jealous of his boats
  437. 15:50perhaps some other things right but I
  438. 15:53want to restore honor to Larry right
  439. 15:55obviously Larry didn't do all the work
  440. 15:56here okay lots of lots of database
  441. 15:58design has did the work for PL SQL right
  442. 16:01um the people have known for a long time
  443. 16:03it's very hard to express business logic
  444. 16:05in declarative ways right so in the 80s
  445. 16:09Oracle came out with something called
  446. 16:10plsql and it stands for programming not
  447. 16:13programming it stands for procedural
  448. 16:14language for SQL so procedural language
  449. 16:17for structured query language not the
  450. 16:19best acronym right but it's the ability
  451. 16:21to do procedural things like if
  452. 16:23statements and control flow inside a
  453. 16:26database query that looks like SQL and
  454. 16:29you might hear these refer to as stored
  455. 16:31procedures they're a stored procedure
  456. 16:33when you store the pl SQL on on the
  457. 16:36database like an API that you can call
  458. 16:38right so this is what it looks like um
  459. 16:41this is the bank transfer example in PL
  460. 16:45SQL it's its own programming language
  461. 16:47right it's got its own Syntax for
  462. 16:49exceptions and I don't think I added any
  463. 16:51logging here I guess there's exceptions
  464. 16:53here you can there's logging you can
  465. 16:55call log statements and you can do all
  466. 16:56sorts of things it's a it's a real PR
  467. 16:58pring language and you can write real
  468. 17:00business logic and run it directly
  469. 17:02within the
  470. 17:04database so why were these invented
  471. 17:08right it was an attempt to make SQL
  472. 17:10queries into a real programming language
  473. 17:13um it's a real programming language
  474. 17:14right it moves business logic to the
  475. 17:17database it supports
  476. 17:18loops and conditional logic it minimizes
  477. 17:22round trips to the database which is
  478. 17:23quite important if you want um good
  479. 17:25performance right instead of having an
  480. 17:26API server sitting somewhere maybe even
  481. 17:29on the edge quite far from your database
  482. 17:31right and your database you know um in a
  483. 17:34different location with all this round
  484. 17:36trip times between your application code
  485. 17:37in Python perhaps and your database it's
  486. 17:39sitting right there inside the database
  487. 17:41without these round trips gives you
  488. 17:43error handling it gives you modularity
  489. 17:46right sick sounds awesome right solves
  490. 17:48all our
  491. 17:50problems we can just run programs in the
  492. 17:54database but I want to go back to this
  493. 17:56paper right this paper keeps bugging me
  494. 17:59right cuz it says no one uses stored
  495. 18:02procedures right why is that why does no
  496. 18:04one use stored
  497. 18:07procedures I think you can guess the
  498. 18:09answer I think you can guess the answer
  499. 18:11because I would ask you do you want to
  500. 18:13use this language to write your
  501. 18:16application because no one wants to use
  502. 18:18a weird esoteric language to write their
  503. 18:20business logic
  504. 18:21right um Andy were you going to jump in
  505. 18:24there I saw you lean in it's based on
  506. 18:27Ada or P like which is the successor to
  507. 18:30Pascal right so it's it's it's from the
  508. 18:3280s it's ugly yes yes and and this is a
  509. 18:35bank transfer that does no Bank does a
  510. 18:38transfer like this right you don't bank
  511. 18:39doesn't do like minus one and plus one
  512. 18:42right there's all sorts of stuff going
  513. 18:43on in there right some fraud detection
  514. 18:45and Computing exchange rates and all
  515. 18:46sorts of things like that right so real
  516. 18:49applications Implement um business logic
  517. 18:51with real libraries and do you want to
  518. 18:53build an entire stack in this
  519. 18:56programming language um that doesn't fit
  520. 18:58at all with your developer workflow you
  521. 19:00probably don't want to use it right so
  522. 19:01people don't use it now stop press I
  523. 19:05realized I got something wrong so as I
  524. 19:07was making these
  525. 19:08slides I Googled how do you implement
  526. 19:12the the bank transfer example in
  527. 19:13superbase quite quite curious if anyone
  528. 19:15had done this right and I found a video
  529. 19:18that actually suggests that you should
  530. 19:20do this using postgress functions and I
  531. 19:22looked into what a postgress function
  532. 19:23was and a postgress function is is um
  533. 19:26something called plpg SQL it's it's PL
  534. 19:28SQL right right um so our boy Larry's
  535. 19:31back right um there is a Resurgence in
  536. 19:35popularity in stored procedures right
  537. 19:38it's not the Oracle version of this it's
  538. 19:40the postgress version which is called
  539. 19:43plpgsql which again fairly terrible
  540. 19:46acronym U but this is still this is not
  541. 19:49this is not how you build your
  542. 19:50application people aren't building real
  543. 19:52business logic in plpg SQL right it's
  544. 19:56just as hard to use as the Oracle
  545. 19:57version right
  546. 20:00so what's wrong with stored procedures
  547. 20:02sometimes you have like a really good
  548. 20:04idea I think stored procedures are a
  549. 20:06really good idea but you're going about
  550. 20:08it the wrong way um and it reminds me of
  551. 20:10this article I just found this article
  552. 20:11just before this talk not wanting to
  553. 20:13pollute the ocean Larry Elon employs a
  554. 20:15man who follows his super yacht in the
  555. 20:17speedboat his sole job is to retrieve
  556. 20:19basketballs to go overboard now I don't
  557. 20:21know if this is true I hope it is it's
  558. 20:23it's a funny article right I felt this
  559. 20:26is amusing this is some good intentions
  560. 20:27but not quite in the execution I think
  561. 20:29stored procedures there's a lot of good
  562. 20:32ideas there not quite right what was
  563. 20:35wrong with stored procedures one it
  564. 20:37doesn't solve your software engineering
  565. 20:39challenges right you want testing and
  566. 20:41types and libraries and git integration
  567. 20:44and standard Lo logging and to use
  568. 20:46Sentry or whatever right you want to be
  569. 20:48in the same language that you always use
  570. 20:50that's the whole software engineering
  571. 20:52thing right so it doesn't solve the
  572. 20:53software engineering challenges and also
  573. 20:56you want some isolation from the
  574. 20:58database so if you work at a um a bigger
  575. 21:00company that has dbas right you should
  576. 21:03go to your dbas and ask them hey can I
  577. 21:06can you install this um plsql store
  578. 21:08procedure for me and they will say no
  579. 21:11right they will say no because they
  580. 21:13don't trust you to run some code inside
  581. 21:16the database right unless your Finance
  582. 21:19you know or using Oracle might be
  583. 21:22different right but for any application
  584. 21:23code databases aren't designed to have
  585. 21:26huge amounts of general purpose compute
  586. 21:27running inside of them right and if the
  587. 21:29plsql goes wrong it can do bad things to
  588. 21:32the database right so typically they
  589. 21:34don't have very good isolation between
  590. 21:35the execution and the storage so good
  591. 21:40idea but it kind of solved none of our
  592. 21:42problems right it was inconvenient to
  593. 21:43write API services but store procedures
  594. 21:46are I think more inconvenient and it
  595. 21:48doesn't make life any better for
  596. 21:49application developers because they have
  597. 21:51to write everything in this weird new
  598. 21:53language and duplicate all their
  599. 21:55business logic into it right and that
  600. 21:56makes Larry Ellison sad right everyone
  601. 21:59critiquing plsql and store procedures
  602. 22:01and I can't stand by and watch that
  603. 22:03happen so what are we going to do about
  604. 22:05that so what if we rethink store
  605. 22:07procedures a little bit right if we go
  606. 22:09back to this code back here where is it
  607. 22:10here we go
  608. 22:13right what if this code was just in
  609. 22:15typescript what if was in a regular old
  610. 22:18programming language that we use all the
  611. 22:19time right what we in the most what if
  612. 22:21it was in the most popular programming
  613. 22:23language in the world right it would
  614. 22:25solve a lot of our software engineering
  615. 22:27problems right if we just integrated it
  616. 22:28directly into our workflow the same
  617. 22:30people writing the application would
  618. 22:32write the queries in the database right
  619. 22:34but then we have to make it safe we have
  620. 22:35to make it sure that it um oh someone
  621. 22:38said isn't SQL the most popular I don't
  622. 22:40know SQL the most popular language I
  623. 22:42don't know let's say let's say close
  624. 22:43enough SQL made the most popular query
  625. 22:45language uh it was uh there was a survey
  626. 22:49last year where from I where SQL is the
  627. 22:51number one programming language that
  628. 22:53students want to know python is number
  629. 22:56two want to know yeah they need for
  630. 22:59their careers I think if you look at
  631. 23:01lines of code getting written these days
  632. 23:03I I believe it's typescript that's my
  633. 23:05but hey maybe I'm wrong it's close
  634. 23:07enough right um I think if you if you go
  635. 23:09build a web app these days it's going to
  636. 23:10be it's going to be JavaScript and
  637. 23:12typescript by the way yes they're the
  638. 23:14same thing effectively right um all the
  639. 23:18stuff I'm going to say applies fairly
  640. 23:19well to JavaScript as well right um so
  641. 23:22we need to make this um yes we get all
  642. 23:25the software engineering benefits we
  643. 23:26have to make it safe right um it feels
  644. 23:29weird to run typescript in our database
  645. 23:31and so we'll get to that right so we can
  646. 23:33move the business logic back to where
  647. 23:35the database is as server functions and
  648. 23:38we just let the application developer
  649. 23:39write it in the language they're already
  650. 23:41using right so let's talk about the
  651. 23:43software engineering experience of
  652. 23:46building a basic app that talks to a
  653. 23:48database using typescript right so
  654. 23:50here's um a basic little shopping cart
  655. 23:53demonstration I've used a few times um I
  656. 23:56guess the source codes online there it's
  657. 23:57obviously a trivial little app right and
  658. 24:00so you can add items to the cart and the
  659. 24:03stock available goes down and the amount
  660. 24:05in your cart goes up and the prices
  661. 24:07increment Etc and this is a multiplayer
  662. 24:10application so if someone else puts the
  663. 24:12hovercraft in their cut it should
  664. 24:14disappear for sale from you right and
  665. 24:16there's lots of different components on
  666. 24:17the screen here that have to stay in
  667. 24:19sync um so how do we write the queries
  668. 24:22well we just write them as regular
  669. 24:23typescript functions that execute
  670. 24:24automically as a transaction here's a
  671. 24:27very very simple function that fetches
  672. 24:29um fetches the items available for
  673. 24:32purchase it just looks up all the items
  674. 24:34table uh where remaining is greater than
  675. 24:37zero but you can do something more
  676. 24:38interesting right so here's here's the
  677. 24:41mutation that adds something to um to
  678. 24:44your cut and it does just the obvious
  679. 24:46things it first checks if you're
  680. 24:47authorized to to do so that's out of
  681. 24:50that's out of screen here I cop that out
  682. 24:52uh then it looks up the items and sees
  683. 24:53if there's a remaining stock and then it
  684. 24:55adds adds it to um the cart and then it
  685. 24:57deducts it from um from available in
  686. 24:59stock and it just does the basic stuff
  687. 25:02in procedural language and in practice
  688. 25:04you'd call out to a bunch of libraries
  689. 25:05to do stuff so in practice when you're
  690. 25:07checking if someone's authorized to do
  691. 25:09something you're not going to manually
  692. 25:11look up the off table there's a library
  693. 25:13that you've written called check or and
  694. 25:15you just call that right so we have
  695. 25:17folks uh using convex who have really
  696. 25:21huge code bases running uh in these
  697. 25:23functions right it's just general
  698. 25:25purpose typescript or
  699. 25:26JavaScript and so the code just sits
  700. 25:28there in your folder hierarchy um with
  701. 25:31the rest of your application code just
  702. 25:32like you're building a regular web app
  703. 25:34right and then you know if you're
  704. 25:35running um you know a a web app and
  705. 25:38you're running mpm runev to
  706. 25:39automatically sync um sync changes to
  707. 25:42your development server it automatically
  708. 25:44syncs all your all your queries too it's
  709. 25:46just this interactive developer
  710. 25:47experience that developers have come to
  711. 25:49expect and and experience right and then
  712. 25:51you can run tests on them right so
  713. 25:53here's a simple test for an app I wrote
  714. 25:55is using Vest V vest vest um so it um it
  715. 25:59does a lot of things it mocks out um the
  716. 26:01user identity it mocks out time it
  717. 26:03advances timer it's obviously a short
  718. 26:05test but you can write this just like a
  719. 26:07real test right which is really really
  720. 26:09hard to do for something like a SQL
  721. 26:11query um and by the way it uses the same
  722. 26:14types as the rest of your application
  723. 26:16not like you know 10 different numeric
  724. 26:18and and and text or blob types like you
  725. 26:21find in in most databases and then with
  726. 26:24all that you get you get type safety and
  727. 26:26you get auto complete like you've to
  728. 26:28expect from a you know a first class app
  729. 26:31development experience you're not kind
  730. 26:32of leaving this nice programming
  731. 26:34language world into this weird text
  732. 26:36based world all of a sudden just to be
  733. 26:38clear the the typescript function is not
  734. 26:41running you're not like converting to
  735. 26:42something that runs in post grass or
  736. 26:44whatever Sy data system is it's there's
  737. 26:46a there's a JavaScript engine s on the
  738. 26:49server side sitting in front of the data
  739. 26:50system Absolutely I'll explain that in a
  740. 26:52second yeah but it's um it's running
  741. 26:54real um real code in V8 yeah got it um
  742. 26:58and um and then you can run rpcs you
  743. 27:01know you can call your client code
  744. 27:02directly you know to call these
  745. 27:04functions like rpcs or you even buy them
  746. 27:07to a to a react component and have your
  747. 27:09client update automatically so this is
  748. 27:12um this is the query this is the um the
  749. 27:14client side code to render all the items
  750. 27:17available for stock and it just binds
  751. 27:19the results of the query called get
  752. 27:21items and just refreshes the component
  753. 27:23anytime um data
  754. 27:25changes so this feels like programming
  755. 27:27because it is it's just programming
  756. 27:29right it's about as ergonomic I think as
  757. 27:31you can get as an application developer
  758. 27:32I think it's kind of the Holy Grail of
  759. 27:34interaction patterns and so you might
  760. 27:36ask why did this not exist already right
  761. 27:39uh one people don't like changing things
  762. 27:42in the database world right and this is
  763. 27:43not written in SQL so I'll give you that
  764. 27:45all right but the other is this has to
  765. 27:47be implemented correctly or it doesn't
  766. 27:49solve a lot of the safety issues I
  767. 27:50mentioned before a lot of the isolation
  768. 27:52issues so what would we have to do to
  769. 27:54kind of convince the DBA that this is
  770. 27:56okay well we'd have to make sure that
  771. 27:59these um these typescript functions
  772. 28:01don't have side effects they don't leak
  773. 28:03any any state out of the transaction and
  774. 28:05we have to make sure that we have pretty
  775. 28:06good isolation from database compute and
  776. 28:09memory and and transaction
  777. 28:12protocol let's talk about the convex
  778. 28:14runtime so the convex runtime is
  779. 28:16implementation of typescript stored
  780. 28:18procedures we have these two concepts of
  781. 28:20queries and mutations queries are pure
  782. 28:22functions they just read data and
  783. 28:24mutations can read and write right um
  784. 28:27the types of system matches JavaScript
  785. 28:29typescript we run I'm putting arbitrary
  786. 28:32in quotes arbitrary typescript there's a
  787. 28:34couple of catches right it's side effect
  788. 28:36effect free so we don't let you call
  789. 28:38fetch we don't let you talk to the file
  790. 28:40system that's that's pretty common and
  791. 28:42pretty easy to do in V8 also we happen
  792. 28:45to make these um these functions
  793. 28:47deterministic so we marck out time and
  794. 28:50random it's a bit of an implementation
  795. 28:51detail that helps with that caching um I
  796. 28:53think you wouldn't necessarily have to
  797. 28:55do that um and we run the
  798. 28:58all in a JavaScript environment that can
  799. 29:00call into the database so here's a
  800. 29:02conceptual model right so you have the
  801. 29:04database yeah you can spin up V8
  802. 29:07contexts these days in hundreds of
  803. 29:08microseconds um and V8 enforces side
  804. 29:12effects free and determinism and then we
  805. 29:14expose the assist calls that let you
  806. 29:17call into the database so db. getet db.
  807. 29:20with index for example and they kind of
  808. 29:21let you call into the database and I'll
  809. 29:23talk more about that in a second um is
  810. 29:25V8 so it actually supports WM um we have
  811. 29:28some some some customers running go code
  812. 29:31uh in these queries so it's not
  813. 29:32specifically typescript um but obviously
  814. 29:34it's more ergonomic um when written with
  815. 29:39typescript um but you can't um you can't
  816. 29:43actually run V8 inside a database oh
  817. 29:45maybe you could but you wouldn't want to
  818. 29:47right because databases aren't designed
  819. 29:48for um being highly efficient Compu
  820. 29:51engines right um in in in the case of of
  821. 29:55convex we do this kind of separating
  822. 29:57storage from exec ution thing right
  823. 29:59where all the concurrency control logic
  824. 30:01is is performed in our backend engine
  825. 30:03but all the index State and storage is
  826. 30:05stored in a big distributed MySQL
  827. 30:06cluster and con convex actually works on
  828. 30:09MySQL and postest and sqlite doesn't
  829. 30:11really matter the differences that from
  830. 30:12my perspective relatively esoteric um so
  831. 30:16the database can focus on doing reliable
  832. 30:18database things and we just run it on
  833. 30:19RDS and then all the kind of um logic
  834. 30:23around transaction coordination and
  835. 30:25executing um code in V8 runs on this
  836. 30:28high performance scale out execution
  837. 30:30cluster right so you might ask well how
  838. 30:33do you get transactionality if the code
  839. 30:35isn't running on the database machine it
  840. 30:37looks a little bit like the API server
  841. 30:39model is it not the same thing as an API
  842. 30:41service um not quite right so um I agree
  843. 30:46real code needs real transactions right
  844. 30:49and so this is even more important when
  845. 30:50you're doing like arbitary code right
  846. 30:53because this code can do a lot of
  847. 30:54complicated things and run lots of
  848. 30:56different C libraries you don't know
  849. 30:58what that library is doing inside of it
  850. 30:59sometimes those libraries talk to the
  851. 31:00database too um it's really nice if that
  852. 31:03can execute as a transaction extra nice
  853. 31:05if it supports serializability you don't
  854. 31:07have to reason about interactions
  855. 31:10between the two different
  856. 31:12functions um and so how do we do it um I
  857. 31:16deleted a slide about why we don't use
  858. 31:18two- face locking I can talk about that
  859. 31:20afterwards if you'd like two- face
  860. 31:21locking gets a little bit complicated
  861. 31:22with deadlock detection and um and and
  862. 31:24locks being held open for too long um
  863. 31:27but we use use a type of optimistic
  864. 31:28concurrency control called multiversion
  865. 31:30concurrency control and you might not be
  866. 31:32familiar you might be familiar but I'll
  867. 31:33explain what these are we use fairly
  868. 31:35standard techniques so we store the data
  869. 31:38in such a way in the database in my SQL
  870. 31:41for example that it's very efficient to
  871. 31:43read a snapshot of the database at a
  872. 31:45given point in time right so so it's
  873. 31:47basically log structured data we can say
  874. 31:49as of this timestamp give me a snapshot
  875. 31:51and for every query we run that query on
  876. 31:54a snapshot and at the at the end we try
  877. 31:57to commit if that snapshot's valid so
  878. 31:59I'll give you a bit more detail
  879. 32:01here I think we do something relatively
  880. 32:04similar to databases like Foundation DB
  881. 32:06maybe 4 DB it's more of a kind of a
  882. 32:08timestamp Oracle kind of model here
  883. 32:10right so um you have this execution ma
  884. 32:14machine sitting there and it gets a
  885. 32:15request to run a query and so it picks a
  886. 32:19time stamp asks an oracle for a time
  887. 32:21stamp time stamp T and then it goes off
  888. 32:23and runs it runs the entire transaction
  889. 32:25as of timestamp t uh and it records and
  890. 32:29remembers all the read ranges all the
  891. 32:31data ranges it reads and then it buffers
  892. 32:33up all the rights he wants to write back
  893. 32:34to the database right and then you get
  894. 32:37to the end of the transaction you have
  895. 32:38to decide is it safe to
  896. 32:40commit so we have a relatively efficient
  897. 32:43structure that can um Can can see if um
  898. 32:47any changes have happened between two
  899. 32:49timestamps so at the end of the
  900. 32:50transaction the latest time stamps time
  901. 32:52stamp n we see if any rights have come
  902. 32:56in that conflict with any of our reads
  903. 32:58if they are that's an optimistic and
  904. 33:00currency control conflict we retry the
  905. 33:02transaction otherwise we just give the
  906. 33:04transaction the latest time stamp and we
  907. 33:06commit it right this might seem a little
  908. 33:08bit complicated if you're new to this
  909. 33:09but it's a it's a pretty standard
  910. 33:11technique um you know I think often
  911. 33:13times you know there's these two ways of
  912. 33:15going down the path of distributed
  913. 33:16databases there's like two-phase commit
  914. 33:17style models and there's like timestamp
  915. 33:19Oracle kind of models and this is more
  916. 33:21the foundation DB way of doing things
  917. 33:28all
  918. 33:29right I'm GNA talk about the query
  919. 33:31language briefly but I think the query
  920. 33:32language is not the most interesting
  921. 33:34part there's a quick question on that
  922. 33:35this is super interesting do you have
  923. 33:38other transaction models too like this
  924. 33:40is not going to get you full
  925. 33:41serializability but maybe that's not the
  926. 33:43goal your applications you're targeting
  927. 33:45may not need that for example you have
  928. 33:47to read whatever you read earlier to get
  929. 33:50that uh uh component so uh are you
  930. 33:54targeting a certain class of
  931. 33:55applications the banking example
  932. 33:56probably needs a little bit more right
  933. 33:58yeah so this this really is serializable
  934. 34:00because we keep uh read ranges
  935. 34:02everything is like we don't we don't
  936. 34:04have like um Phantoms for example like
  937. 34:06we are keeping real read ranges um but
  938. 34:09at the end I'm going to talk a bit about
  939. 34:10serializability because there are
  940. 34:12situations where you don't want
  941. 34:13serializability and I and so we'll put
  942. 34:15that in Hollow them we'll come back to
  943. 34:16that towards the end because I want to
  944. 34:17talk about situations where you want
  945. 34:18want to um um relinquish
  946. 34:22serializability um thank
  947. 34:25you yeah yeah um
  948. 34:29and okay let's let's where are we cool
  949. 34:30so I'll talk about the query model again
  950. 34:32can I can I ask one question here so you
  951. 34:35obviously decided to implement
  952. 34:37transactions in the V8 containers rather
  953. 34:39than reuse the transactions that exist
  954. 34:41in MySQL or
  955. 34:42postest you could have you could have
  956. 34:45done that you could have inserted a big
  957. 34:47begin transaction end transaction and
  958. 34:49you could have used the backend
  959. 34:51transactions not to yes so so the way we
  960. 34:56actually use the database
  961. 34:58um is not um how to describe it we use
  962. 35:01MySQL basically as a as a wrer head
  963. 35:04log um so as a version right ahead log
  964. 35:07so basically we store um all all the
  965. 35:10timestamps and and and and the states as
  966. 35:12as of that timestamp um and then and
  967. 35:15obviously the indexes as well all the
  968. 35:17transaction coordination logic is done
  969. 35:19in um in user space I guess or in our
  970. 35:22rust codebase so um we really use the
  971. 35:26database when it comes comes down to it
  972. 35:28for a durable wrer head log um and the
  973. 35:31ability to perform queries on the on on
  974. 35:34on a on a on a um timestamp
  975. 35:36snapshots um and and this gives us the
  976. 35:39ability to
  977. 35:40um well it gives us the ability to to to
  978. 35:43have our own kind of custom schema like
  979. 35:45like the the user schema for example is
  980. 35:47not in the database right everything is
  981. 35:50done application Level right we can do
  982. 35:52our own concurrency control um and then
  983. 35:55really we're using the database as a
  984. 35:56storage engine
  985. 35:58and I can talk in more detail about that
  986. 36:00towards the end um if there if there's
  987. 36:02more questions so the back end could
  988. 36:03have been a regular key Value Store it
  989. 36:05didn't have to be a abely post it could
  990. 36:09be a key value store that allowed range
  991. 36:11reads right because we do um we do treat
  992. 36:14it somewhat like a like a b tree um so
  993. 36:17so we um our query actually I'll talk
  994. 36:19about the query model right now our
  995. 36:21query model is just ranges of berries
  996. 36:22really um and so um we don't have a
  997. 36:26query planner and that was a choice we
  998. 36:28made um it was a choice we made based on
  999. 36:31our experience running large databases
  1000. 36:33right because in in large organizations
  1001. 36:35you don't really want a query planner in
  1002. 36:37fact in any large installation I've seen
  1003. 36:40you typically Force indexes and and use
  1004. 36:42pretty limited subsets of SQL and you're
  1005. 36:44not doing you know random joins in in
  1006. 36:47production um so our our kind of
  1007. 36:50postulate is that um it's sufficiently
  1008. 36:52ergonomic to just to just describe your
  1009. 36:55queries in a declarative way in in an
  1010. 36:57imperative way rather than having to
  1011. 36:59have a query planner in there that slows
  1012. 37:01things down and can make things
  1013. 37:03non-deterministic and also could lead to
  1014. 37:05unexpected performance degradation um we
  1015. 37:09could have supported SQL in this model
  1016. 37:11and I'll talk about that a little bit
  1017. 37:12later as well right so our query model
  1018. 37:14literally is either get from an ID and
  1019. 37:18internally that gets translated from get
  1020. 37:20from an ID and our query language to
  1021. 37:22underneath get from an ID and a Tim
  1022. 37:24stamp or it's range scan over a table or
  1023. 37:28range scan over an index and then
  1024. 37:31internally that's translated down to
  1025. 37:32range scan over um an index as of a
  1026. 37:36timestamp and so that's all we require
  1027. 37:38from the database right um so this is
  1028. 37:41this is how um this is how reads happen
  1029. 37:44um you know query with index and then
  1030. 37:46you can range over that
  1031. 37:47index you can insert um now everything
  1032. 37:51else in convex is in user space right
  1033. 37:53and this is maybe a maybe a contentious
  1034. 37:56thing so if you want to do a join in
  1035. 37:58convex you just do it in the application
  1036. 38:00Level um now what is a join I think
  1037. 38:03people have this um perception a lot of
  1038. 38:06people who use SQL think joins are
  1039. 38:07somehow magical that somehow the
  1040. 38:09database can do some magic query
  1041. 38:11planning thing that doesn't look like
  1042. 38:13walking over a table and looking up
  1043. 38:14another table typically that's that's
  1044. 38:16that's not happening right so so if you
  1045. 38:19want to do a joint in convex we do that
  1046. 38:20at the application Level in parallel
  1047. 38:22just like this using a parallel map um I
  1048. 38:26think in practice this is maybe a little
  1049. 38:28bit inconvenient right and so we have a
  1050. 38:30helper for joins and we're going to have
  1051. 38:31a new version of um a new version of
  1052. 38:34convex that will have better support for
  1053. 38:36joins just just as a as a concession
  1054. 38:38towards um user ergonomics um but but
  1055. 38:42you know basically the the a core part
  1056. 38:44of convexes um API is to make expensive
  1057. 38:49things look expensive and make cheap
  1058. 38:51things look cheap um so we want joint we
  1059. 38:53want a joins to look like a what a
  1060. 38:55joint's doing um
  1061. 38:58now that said SQL could compile down to
  1062. 39:01this too right we could take a SQL
  1063. 39:03statement obviously we'd want the
  1064. 39:04typescript there but the actual queries
  1065. 39:06that do like db. getet or whatever you
  1066. 39:08could write them in SQL right and we
  1067. 39:10could run a static query planner and
  1068. 39:11compile them down to range scans on the
  1069. 39:13database um and we actually used to have
  1070. 39:16this the very early version of convex
  1071. 39:18had this in there we stripped it out it
  1072. 39:19was getting a bit clunky um it's not
  1073. 39:21type safe it's less expressive um but
  1074. 39:24hey there's a there's a possibility we
  1075. 39:25add this back sometime if people really
  1076. 39:27want to run a SQL query instead of
  1077. 39:29calling with index whatever there's
  1078. 39:31nothing stopping us doing that right all
  1079. 39:33we have to do is translate this down
  1080. 39:34into range scans as of a timestamp and
  1081. 39:37that's what's going on underneath um
  1082. 39:39underneath our
  1083. 39:40system
  1084. 39:42cool
  1085. 39:43um so how does the world look different
  1086. 39:46now that we can run code in the database
  1087. 39:49right so we've kind of we've I'm going
  1088. 39:51to I'm going to claim that we've solved
  1089. 39:53the ergonomics and the isolation
  1090. 39:54problems but what else can we get what
  1091. 39:56other benefits can we get well one is
  1092. 39:58that caching comes for free and when I
  1093. 40:00say caching I don't mean um row caching
  1094. 40:03I mean query
  1095. 40:04caching so caching validation is
  1096. 40:07classically one of the hardest problems
  1097. 40:08in computer science query caching is
  1098. 40:10when you cache the result of a function
  1099. 40:13so you run some complicated thing read a
  1100. 40:15whole bunch of data do some computation
  1101. 40:17um and then you cach the result of that
  1102. 40:19right uh query caching is is is really
  1103. 40:23powerful it's a very efficient way to
  1104. 40:24cach you don't have to run use code over
  1105. 40:25and over again but it's very hard hard
  1106. 40:27to do right manually managing a query
  1107. 40:29cach is quite tricky right but in compex
  1108. 40:32caching comes for free because we know
  1109. 40:34the reads set for every query and we
  1110. 40:36know the right set for every mutation
  1111. 40:39and we have an an efficient intersection
  1112. 40:40mechanism for um for determining whether
  1113. 40:43a mutation intersects with a with a
  1114. 40:46reset so we just cash a query until it's
  1115. 40:49invalided about mutation right um you
  1116. 40:51get that for free right and so you might
  1117. 40:53say well caching is hard right there's a
  1118. 40:55lot of gotchas when it comes to caching
  1119. 40:57and and and you're right there are a lot
  1120. 40:59of gotchas
  1121. 41:00um I'll give you an example of a gotcha
  1122. 41:03with caching just say we we cach a
  1123. 41:05result of a query with a certain version
  1124. 41:07of the source code and then you go and
  1125. 41:09change the source code you go and you
  1126. 41:11know change the story procedure to do
  1127. 41:12something slightly different you'd have
  1128. 41:14to go and invalidate all those previous
  1129. 41:16cach values right and so typically when
  1130. 41:18people are writing caching code partly
  1131. 41:20why they consider it so hard is all the
  1132. 41:22corner cases and gotches you have to
  1133. 41:23deal with right but in convex these
  1134. 41:25problems just go away um automatically
  1135. 41:28for example in the source code example
  1136. 41:31every query depends on its source code
  1137. 41:33every query has to read its source code
  1138. 41:35before it runs so the source code is in
  1139. 41:38the read set for the query and if you
  1140. 41:40upload a new version of that of that
  1141. 41:42source code that's a mutation that
  1142. 41:44invalidates that previous the previous
  1143. 41:46uh read set right and so that is
  1144. 41:48conflicts and invalidates the
  1145. 41:51cache but also if you have caching if
  1146. 41:53you have query caching subscriptions
  1147. 41:55come for free right because if if you
  1148. 41:57know whenever data is is whenever the
  1149. 41:59result of a query changes you can just
  1150. 42:01subscribe to that query you can say give
  1151. 42:03me the latest version of that query
  1152. 42:05whenever the data changes underneath and
  1153. 42:06you can do that very efficiently you
  1154. 42:08don't have to do this kind of spin
  1155. 42:09looping or polling you get this for free
  1156. 42:12so what can you do with subscriptions
  1157. 42:14well you can build a sync protocol right
  1158. 42:16this is kind of the end of polling you
  1159. 42:18don't have to you know you're pushing
  1160. 42:19the interface with the database right
  1161. 42:21out to the application Level right where
  1162. 42:23you can just say bind the results of
  1163. 42:26this query
  1164. 42:27to this
  1165. 42:28component and refresh whenever the data
  1166. 42:31changes so this was the query to this
  1167. 42:33was the react code to render the items
  1168. 42:36list um and as you see here in the left
  1169. 42:40every time the data changes on the on
  1170. 42:42the back end that component just
  1171. 42:43refreshes automatically there's no need
  1172. 42:45for um no need for manual polling logic
  1173. 42:48or manual consistency logic um so if
  1174. 42:50you're familiar with react and
  1175. 42:52functional paradigms that update
  1176. 42:53components whenever data changes this
  1177. 42:55will be very familiar with you it's just
  1178. 42:57react but it react all the way to the
  1179. 43:00database um and again there's a there
  1180. 43:03always gotes right and so you got to
  1181. 43:04kind of um pressure test this to see if
  1182. 43:06it's if it's designed correctly right do
  1183. 43:09we get true endtoend
  1184. 43:12consistency because there's at least two
  1185. 43:14queries here there's a query that gives
  1186. 43:16you the list of items for sale and the
  1187. 43:18query that gives you all the items in
  1188. 43:20your card and it would be pretty
  1189. 43:21unfortunate if these got out of sync if
  1190. 43:24you if you had something in your cart
  1191. 43:26but it wasn't in your or um if it was
  1192. 43:28still in available for sale and a lot of
  1193. 43:30um complex logic and a lot of modern
  1194. 43:33applications deals with State Management
  1195. 43:35how to keep all the stuff in sync with
  1196. 43:37each other right but in convex this
  1197. 43:39problem is done automatically for you
  1198. 43:41because we know what queries have
  1199. 43:43subscribed to and all this stuff is
  1200. 43:45serialized over a websocket so we just
  1201. 43:47send you all the changes in lockstep you
  1202. 43:48get the changes in a Serial order and if
  1203. 43:51two if two um queries are invalidated at
  1204. 43:53the same time those components will
  1205. 43:55Refresh on the browser
  1206. 43:58atomically all right awesome we have
  1207. 44:00real store procedures they're expressive
  1208. 44:03and they're ergonomic to use Larry is
  1209. 44:05happy he was right all along this is a
  1210. 44:07real book by the
  1211. 44:08way U it's the difference between God
  1212. 44:12and Larry Ellison God doesn't think he's
  1213. 44:13Larry Ellison so that's the updated
  1214. 44:16cover but yes are you you've got this
  1215. 44:19book Andy I give it out I used to give
  1216. 44:20it out the students wow okay maybe I
  1217. 44:23should read it maybe I should read it
  1218. 44:26I'll after us keep going okay um and by
  1219. 44:29the way I'm just talking about Larry
  1220. 44:31ellon because there's lots of funny
  1221. 44:32pictures about Larry ellson obviously
  1222. 44:34props to the engineers and and database
  1223. 44:36researchers who designed all this stuff
  1224. 44:37originally right cool so we have store
  1225. 44:40procedures and Andy someone I care about
  1226. 44:42can go back to having a happy fulfilling
  1227. 44:44life except there was two claims in that
  1228. 44:47paper right it's a long paper so you
  1229. 44:49might have missed it the two claims
  1230. 44:50where no one uses store procedures and
  1231. 44:52no one uses
  1232. 44:53serializability and why don't people use
  1233. 44:55serializability cuz there's a belief
  1234. 44:57that serializability doesn't scale and
  1235. 44:59it's not a dumb belief like there's
  1236. 45:00reasons for this belief so what is
  1237. 45:02serializability um probably most people
  1238. 45:05on this call know what serializability
  1239. 45:06is serializability um in some extent is
  1240. 45:09the strongest version of consistency
  1241. 45:12slightly less than linearizability right
  1242. 45:14but serializability means that if you
  1243. 45:16have a serializable database and you
  1244. 45:18interact with it multip people
  1245. 45:19interacting with it at the same time it
  1246. 45:21looks as if to the users everyone's
  1247. 45:24running it one at a time in a Serial
  1248. 45:26order right you don't have to to think
  1249. 45:27about what anyone else is doing you
  1250. 45:28don't need stuff like select for update
  1251. 45:30and all these all these scotches the
  1252. 45:32serializability does have scaling
  1253. 45:34limitations right because if you have
  1254. 45:37queries that touch each other's data in
  1255. 45:39every query they can only happen one at
  1256. 45:41a time and if they can only happen one
  1257. 45:43at a time you can only get as much
  1258. 45:44throughput as the latency it takes to
  1259. 45:47run you know a single um single query
  1260. 45:50now in practice worldd designed apps um
  1261. 45:54try to design them in such a try to be
  1262. 45:56uh application developers try to design
  1263. 45:58their their queries in such ways that
  1264. 45:59they don't conflict with each other
  1265. 46:01right but sometimes you don't need
  1266. 46:04serializability sometimes what you want
  1267. 46:06is asynchrony so asynchron is a very
  1268. 46:08important um property of a of a of a
  1269. 46:11system with strong guarantees right your
  1270. 46:13database gives you serializability if
  1271. 46:16you want it but you can also opt out to
  1272. 46:19just doing things later right so because
  1273. 46:22we control the runtime in convex we just
  1274. 46:24added a schuer to it right so there's
  1275. 46:27also uh a function called ctx.edu Runa
  1276. 46:31this this is actually saying run after
  1277. 46:33zero and what this is saying is once
  1278. 46:35this mutation
  1279. 46:36commits just just run this other
  1280. 46:39function later on you know immediately
  1281. 46:42after um whenever you get a chance it
  1282. 46:43looks some so you can you can also run
  1283. 46:46after one second there's various things
  1284. 46:48you can do with a scheduler but the
  1285. 46:49ability to run scheduling and by this is
  1286. 46:52this is scheduling State that's
  1287. 46:53committed to the database and is
  1288. 46:55transactional right so the the ability
  1289. 46:57to do scheduling allows you to chain
  1290. 47:00together the uh you know these these
  1291. 47:02transactions into workflows that
  1292. 47:03resemble something like temporal you
  1293. 47:05know but have them be transactionally
  1294. 47:07consistent with the
  1295. 47:09database all right I've talked about
  1296. 47:12queries as code right they allow you to
  1297. 47:14express business logic in
  1298. 47:16typescript they're deeply integrated
  1299. 47:18with application developer workflow so
  1300. 47:20app developers can can use them happily
  1301. 47:23they provide you consistency and
  1302. 47:24isolation so you can build correct apps
  1303. 47:27that don't get over complicated and you
  1304. 47:29get catching and subscriptions and sync
  1305. 47:31for free so you don't need to do stuff
  1306. 47:33like polling and and and cash and
  1307. 47:35validation right and something I didn't
  1308. 47:37have time to talk about but is kind of
  1309. 47:40real new research we're doing we're
  1310. 47:42finding that um llms really love writing
  1311. 47:46queries as code right um for a variety
  1312. 47:48of reasons one strong type safety and
  1313. 47:51and and and and good highle building
  1314. 47:53blocks but also you can build good evals
  1315. 47:56very easily so if you're writing queries
  1316. 47:58as code that have strong guarantees that
  1317. 48:00commit automically that have
  1318. 48:02serializability right it's very easy for
  1319. 48:04an LM to attempt to build something and
  1320. 48:06then run tests to see if it works so um
  1321. 48:08we've got some more um um information
  1322. 48:11coming out soon but we're getting very
  1323. 48:12very promising um results uh using llms
  1324. 48:16to to to write convex code in particular
  1325. 48:19um and so you know kind of furthers my
  1326. 48:21belief that you know what's good for the
  1327. 48:22humans is good for the robot uh and vice
  1328. 48:24versa so that's it that's that's that's
  1329. 48:26that's my argument towards queries is
  1330. 48:28code um and I tried to keep this pretty
  1331. 48:30General and not about convex I just
  1332. 48:32think this is a this is a good idea in
  1333. 48:34general all the stuff does exist it's
  1334. 48:37available at convex dodev you can use it
  1335. 48:39today thanks awesome I will slap on
  1336. 48:43behalf of everyone here uh James
  1337. 48:45fantastic uh we have about 10 minutes or
  1338. 48:47so uh for questions so if you have a
  1339. 48:48question for James go ahead and unmute
  1340. 48:50yourself and fire
  1341. 48:52away James this was an excellent talk of
  1342. 48:56so Oracle and snowflake has JavaScript
  1343. 49:00as a stored procedure as a UDF language
  1344. 49:05yeah does that get you a back door to
  1345. 49:07doing this without having to do all the
  1346. 49:09other setup in the database or you still
  1347. 49:12uh need all the other additional service
  1348. 49:15side stuff that you're doing that's a
  1349. 49:16good question now I mean snowflake it's
  1350. 49:19quite different right so snowflake could
  1351. 49:20be all app all app right I mean
  1352. 49:22presumably offering in the all app
  1353. 49:23product um and I'm not familiar with
  1354. 49:27with um I'm not familiar with udfs in
  1355. 49:30Oracle um but I I imagine I mean if
  1356. 49:33they're doing something like this
  1357. 49:34similar to this that's great but I think
  1358. 49:36what makes this powerful is is really
  1359. 49:39putting it in the developer workflow the
  1360. 49:41customers of this uh web developers and
  1361. 49:44application developers the customers
  1362. 49:45aren't dbas you know and so I'd be quite
  1363. 49:49curious as to the ergonomics of that and
  1364. 49:52and and how well that that fits into the
  1365. 49:53platform but you know um in terms of how
  1366. 49:56this is so comvex is open source
  1367. 50:00um at um on Thursday so um in in you
  1368. 50:03know 3 days from now um we we're open
  1369. 50:06sourcing a version that um right now the
  1370. 50:09open source comvex runs on sqlite we're
  1371. 50:11open sourcing the the version that runs
  1372. 50:13on on distributed MySQL and on postgress
  1373. 50:16um and so for us it's um it's
  1374. 50:18advantageous to have this pretty clear
  1375. 50:20separation between the storage layer and
  1376. 50:23and the rest of of of comx and you know
  1377. 50:25I I have built storage before I don't
  1378. 50:27particularly want to build a storage
  1379. 50:28engine again so for us it's nice being
  1380. 50:30able to use an off-the-shelf storage
  1381. 50:33engine good I have a second question
  1382. 50:35that I see else wants to
  1383. 50:38go I I saw a question come through here
  1384. 50:42um why isn't the pl seel something like
  1385. 50:44WM where you could easily Implement
  1386. 50:45compilers from different languages
  1387. 50:46throughout the need for extra va8
  1388. 50:47context perhaps why not even Implement a
  1389. 50:50DB that uses wasm as a store procedure
  1390. 50:52language yeah that's interesting um so
  1391. 50:56yes this um this is um this does support
  1392. 50:58WM right so so V8 will execute wasm code
  1393. 51:01for you um we very occasionally do that
  1394. 51:04um we haven't had tremendous demand from
  1395. 51:08folks wanting language other than
  1396. 51:10typescript um although that this could
  1397. 51:13be selection bias um but I I think the
  1398. 51:16ability um supporting typescript and
  1399. 51:20having like nice typescript types and
  1400. 51:21having a really ergonomic um interface
  1401. 51:24for using typescript has been what
  1402. 51:26people have been happy with so far um
  1403. 51:28but yeah I mean I'd totally be down to
  1404. 51:30support other languages um but I do
  1405. 51:33think you know now you have this
  1406. 51:35question about is V8 the right
  1407. 51:37runtime um because V8 is not as
  1408. 51:41expressive as node for example right so
  1409. 51:43so you can't run necessarily depending
  1410. 51:46on what what um what run time you're
  1411. 51:48running you can't necessarily run all
  1412. 51:49Library functions um in V8 um but the
  1413. 51:53nice thing about V8 is makes it very
  1414. 51:54easier for us to to kind of intercept um
  1415. 51:58calls to the database Etc um but yeah I
  1416. 52:01think pretty key to this is this
  1417. 52:04separation of storage and execution I I
  1418. 52:06I'm I'm not really going to advocate for
  1419. 52:09someone running real code in a database
  1420. 52:12um unless we design the database from
  1421. 52:14the ground up and yes we could do that
  1422. 52:15but you know databases are complicated
  1423. 52:17enough as as they are they they have
  1424. 52:19enough um you most of them have 30 years
  1425. 52:22of baggage about you know managing State
  1426. 52:25and memory Etc um and I don't think
  1427. 52:28throwing like general purpose compute in
  1428. 52:30them is is The Right
  1429. 52:32Move um is is conx handle ordering in
  1430. 52:37the client side H for getting the events
  1431. 52:40and
  1432. 52:41everything yeah so um there is a there
  1433. 52:43is a sync protocol and so my um two
  1434. 52:46co-founders Jamie and sujay um actually
  1435. 52:48wrote the the Dropbox sync protocol so
  1436. 52:50they wrote the desktop client at um at
  1437. 52:53Dropbox and so they've got a lot of
  1438. 52:55experience building syn protocols and so
  1439. 52:57we actually have a a websocket protocol
  1440. 52:59when you're um writing a convex app uh
  1441. 53:02typically there's a single websocket
  1442. 53:04that's sitting there and all um requests
  1443. 53:06and responses go over that websocket um
  1444. 53:08there are kind of out of band ways of
  1445. 53:10sending requests out of band to avoid
  1446. 53:12head of line
  1447. 53:13blocking um but um we order all updates
  1448. 53:18um serially over the websocket so
  1449. 53:20there's no reorderings required locally
  1450. 53:22um but yeah so the the the there's a
  1451. 53:24there's like a a client Side Library
  1452. 53:26which does all this ordering going up to
  1453. 53:28the to the to the back end and on the
  1454. 53:31way back this is for the sync side of
  1455. 53:33convex you can also just use convex like
  1456. 53:35an RPC server you could just call um an
  1457. 53:38HTP end point and talk to the database
  1458. 53:40like that but without any of the and the
  1459. 53:42syn and then you wouldn't get end to-end
  1460. 53:43consistency you'd only get consistency
  1461. 53:45in the
  1462. 53:51database James if I may um I I'll first
  1463. 53:54ask a question and then provide a bit of
  1464. 53:56a interesting context for it uh so uh
  1465. 54:00just as a confirmation as I imagined
  1466. 54:02conx convex is designed for mostly
  1467. 54:07transactional
  1468. 54:09ootp loads and not not for all app like
  1469. 54:13analytical queries and whatnot yeah I
  1470. 54:15have a lot to talk about that but yes
  1471. 54:16the the short answer is yes it's forp
  1472. 54:19but there it's an interesting discussion
  1473. 54:20there uh because fun fact I work at a
  1474. 54:23company which writes all of it business
  1475. 54:25logic in SQL we have very difficult
  1476. 54:28networking algorithms completely encoded
  1477. 54:30in sqo which frequently have like 15
  1478. 54:32joints and uh and in the process of
  1479. 54:36working with it I came come came to the
  1480. 54:38appreciation of how extremely complex uh
  1481. 54:41SQL op query optimization engines are
  1482. 54:44and how much they filter out unnecessary
  1483. 54:47computation and I it came to my mind
  1484. 54:49when I saw your example uh of like
  1485. 54:52everything being in user space where you
  1486. 54:54sort of uh queried over one one table
  1487. 54:57and then joined it with another and you
  1488. 54:58loaded everything into the memory and
  1489. 55:00you sort of join them manually and I can
  1490. 55:03imagine that would be very very slow
  1491. 55:05when you have like a sort of an
  1492. 55:07analytical workload or or a query which
  1493. 55:10like simply does a join over to Big
  1494. 55:13tables do you have do you have plans for
  1495. 55:16adding sort of I would imagine a library
  1496. 55:20that would
  1497. 55:21um hide the complexity of doing a proper
  1498. 55:25join like let's say like all the join
  1499. 55:27algorithms that postgress has I don't
  1500. 55:29know mer join hash join Etc that hides
  1501. 55:31this behind and hides hides this behind
  1502. 55:34the scenes and sort of allows you to
  1503. 55:36write efficient analytical workloads
  1504. 55:39yeah this is a great question so so
  1505. 55:41firstly yes convex is designed for live
  1506. 55:43site ootp workloads where you want your
  1507. 55:45queries to be relatively fast because
  1508. 55:47there's a user in the critical path and
  1509. 55:49I I should have made this more clear but
  1510. 55:51almost everything I'm saying today is
  1511. 55:53really about olp I think ol's quite
  1512. 55:55different because I think the difference
  1513. 55:56is typically with olp you know um what
  1514. 56:00you want and you know how to achieve it
  1515. 56:02generally it's it's relatively simple
  1516. 56:03things like oh you know um add this
  1517. 56:05person to this thing look up this state
  1518. 56:06right whereas olap is is obviously by
  1519. 56:09definition more analytical right you
  1520. 56:11kind of want some kind of answers you
  1521. 56:13don't necessarily know how to fetch them
  1522. 56:15and you and you don't care about tight
  1523. 56:17latency guarantees with olap typically
  1524. 56:19right so olap quite different the
  1525. 56:21planning is really important because
  1526. 56:22there's huge amounts of data getting
  1527. 56:23queried um and you have they come with a
  1528. 56:26complex query plan and so I'm pretty
  1529. 56:28like down with like um with with um
  1530. 56:31declarative query models for olap I
  1531. 56:34think makes a lot of sense um I think
  1532. 56:36olp typically almost everything you're
  1533. 56:38doing is indexed right if you're doing
  1534. 56:40any kind of complex like um query
  1535. 56:43planning in an olp query is probably
  1536. 56:45something going wrong right um so so so
  1537. 56:49there's two things you said there one
  1538. 56:50about joins one about what about if you
  1539. 56:52want to do analytics right so joins yeah
  1540. 56:54there's a few things we could do we
  1541. 56:55could do push down so so right now
  1542. 56:57you're right like we do um read all that
  1543. 57:00St to memory right um now there's
  1544. 57:02there's optimizations we do prefetching
  1545. 57:04we do various things under the covers
  1546. 57:06right we could also do push down where
  1547. 57:08we we statically analyze the code and um
  1548. 57:11and Implement more of it on the data um
  1549. 57:15we don't do that right now to a very
  1550. 57:18extensive degree um and also I think I
  1551. 57:21think we probably should add a join
  1552. 57:22helper to be honest I think you're right
  1553. 57:23yeah but the other thing you touched on
  1554. 57:26is is analytics so I have no ambition to
  1555. 57:30compete with with Snowflake and data
  1556. 57:31bricks right but every now and then in a
  1557. 57:35in a website in a live app you want to
  1558. 57:37do something kind of i' call baby all
  1559. 57:39app right you want to like read over all
  1560. 57:41your users and complete the high score
  1561. 57:42compute the high score or something and
  1562. 57:44it's not easy to do that efficiently um
  1563. 57:46and so even if sometimes a query takes
  1564. 57:4830 seconds so we don't we only we don't
  1565. 57:51allow you to run like a 30 second query
  1566. 57:53right we keep everything very tight so
  1567. 57:54it's so it's it's high performance I
  1568. 57:56think there's room for allowing people
  1569. 57:58to run less efficient queries and um
  1570. 58:01we're exploring two things currently one
  1571. 58:04is keeping these snapshots around a lot
  1572. 58:05longer so right now it's with retention
  1573. 58:07it's a little bit hard for us to keep
  1574. 58:09these snapshots around for a long time
  1575. 58:10at a time stamp um and if we keep them
  1576. 58:13around longer you could just run a a
  1577. 58:14really long query a stale query um the
  1578. 58:18other is we have a prototype of running
  1579. 58:20duck DB on convex where we just um dump
  1580. 58:23all our data in Duck DB now assuming
  1581. 58:25it's it tractable data sizes to be
  1582. 58:27queried by dub um anyway I guess the
  1583. 58:31short answer is uh after a long answer
  1584. 58:33is that you're you're right this is
  1585. 58:35really targeting allp but there is a
  1586. 58:37demand I think for for baby olap right
  1587. 58:40for little analytics and I think we need
  1588. 58:42to add some more features for
  1589. 58:44that and thank you a lot thanks a lot
  1590. 58:46and a very short uh like sort of upper
  1591. 58:49upcoming question uh as a developer of
  1592. 58:53Bas of of Conex do you think it is
  1593. 58:56possible at all to sort of do an a
  1594. 58:59complex analytical join in a language
  1595. 59:02like tab script without encoding your
  1596. 59:04queries farer in like SQL and sending
  1597. 59:06them to the database and getting the
  1598. 59:08results back like does it would it be
  1599. 59:11ever possible to fit that logic into
  1600. 59:14like an imperative language yeah Andy
  1601. 59:16would know the answer better than me but
  1602. 59:17there are people doing this right people
  1603. 59:19are using imperative languages for
  1604. 59:22analytics queries people did that
  1605. 59:24with doop that's dead right there's so
  1606. 59:27many different choices you have to make
  1607. 59:28on on an optimal query plan you do not
  1608. 59:30want your programmer writing this right
  1609. 59:33this is the the classic squel debate
  1610. 59:35from the 1970s right because any
  1611. 59:38assumption you bake in your code about
  1612. 59:40what should be the right join not or or
  1613. 59:41how to push down C you know certain
  1614. 59:44operators if the data evolves and
  1615. 59:46changes you don't want to go back and
  1616. 59:47rewrite all your
  1617. 59:49code so you for baby things sure or like
  1618. 59:53again the you know go- getting the last
  1619. 59:5510 things but like uh anything anything
  1620. 59:59very complicated it's be a bad
  1621. 1:00:04idea okay
  1622. 1:00:07um yes there's there's there's that
  1623. 1:00:09paper yes from I just saw a comment
  1624. 1:00:11about stat I I'm not familiar with his
  1625. 1:00:12work but I do know both Alvin Alvin and
  1626. 1:00:15Sam so I should check out status quo
  1627. 1:00:17Alvin's PG thesis was on um uh basically
  1628. 1:00:20pushing down like hibernate code like if
  1629. 1:00:23if it detects you're doing a join in
  1630. 1:00:25Java it then pushes that down to the DAT
  1631. 1:00:27Ser but it can actually move it back and
  1632. 1:00:28forth based on the load of the
  1633. 1:00:30system other thing I'll say is I'm not
  1634. 1:00:33I'm not particularly like anti- query
  1635. 1:00:35planning right I think uh I I prefer for
  1636. 1:00:39all Top's static query planning at least
  1637. 1:00:42so you know what's going to happen in
  1638. 1:00:43production right but I think um th this
  1639. 1:00:47this this Paradigm is is is compatiable
  1640. 1:00:50with query planning where that makes
  1641. 1:00:52sense right like I said like we've
  1642. 1:00:53chosen to use a very imperative Style of
  1643. 1:00:56querying uh where you're traversing over
  1644. 1:00:58be basic be ranges but but um I think
  1645. 1:01:01the the key Point here is the queries is
  1646. 1:01:03code and there and you could you could
  1647. 1:01:04run it with with some kind of assistance
  1648. 1:01:06by even you know llm based assistance
  1649. 1:01:09you know you're you're in programming
  1650. 1:01:11language territory um then so so um
  1651. 1:01:14there's there's lots you can
  1652. 1:01:16do my last question was more
  1653. 1:01:18clarification like you have this
  1654. 1:01:21middleware that sits in front of the the
  1655. 1:01:23databas server and then the the
  1656. 1:01:24typescript piece that's trying to
  1657. 1:01:26determine the serial ordering of
  1658. 1:01:28transactions is that assuming that the
  1659. 1:01:31database server is like a like a primary
  1660. 1:01:34replica set up so that you would then do
  1661. 1:01:36the right to the primary and let the D
  1662. 1:01:38server replicate it to the replica or is
  1663. 1:01:40that middleware potentially sending it
  1664. 1:01:42out to different nodes or you know
  1665. 1:01:44instances and doing like a you multi-
  1666. 1:01:46primary write up multi home write up
  1667. 1:01:48right yeah so so there's not multi-
  1668. 1:01:49primary right so so you so there's
  1669. 1:01:52there's a few um points of nonscale in
  1670. 1:01:57the system right one is you have to have
  1671. 1:01:58a time stamp Oracle right now it turns
  1672. 1:02:00out you can scale this pretty widely if
  1673. 1:02:03you all all you're doing is picking time
  1674. 1:02:04stamps you you can run a lot of
  1675. 1:02:05transactions per second through that and
  1676. 1:02:07the SEC and then you need um to install
  1677. 1:02:10your rights into a primary right but but
  1678. 1:02:14once you have a a time stamp you are
  1679. 1:02:16able to go and read um that snapshot
  1680. 1:02:18wherever you that snapshot's available
  1681. 1:02:20uh you could even we don't do this but
  1682. 1:02:22you could read that Snapshot from from
  1683. 1:02:23S3 if you needed to you know but um but
  1684. 1:02:25basically
  1685. 1:02:27um when you commit a transaction at the
  1686. 1:02:30end you're just installing right it's
  1687. 1:02:32just taking a a bulk set of data updates
  1688. 1:02:34and you're putting them into the
  1689. 1:02:35database as of a time stamp got it okay
  1690. 1:02:38awesome all right uh let's get i'll for
  1691. 1:02:42James fantastic talk thank you for
  1692. 1:02:43kicking this off was very um a lot of
  1693. 1:02:46people still stuck around to the very
  1694. 1:02:48end that's how you know it's a good talk
  1695. 1:02:49okay this go ahead yeah sorry yeah I say
  1696. 1:02:53I saw those I saw I think Chris had a
  1697. 1:02:55question if people have more questions
  1698. 1:02:56Reach Out feel free to hit me up on um
  1699. 1:02:58on uh X Twitter it's just James a
  1700. 1:03:01cowling um and um or or try it out we
  1701. 1:03:05also have a blog post called how convex
  1702. 1:03:07Works which talks in a little bit more
  1703. 1:03:08detail about the transaction
  1704. 1:03:09coordination protocol
  1705. 1:03:12[Music]

About this transcript

This page contains the full transcript of Larry Ellison was Right (kinda)! TypeScript Stored Procedures for the Modern Age (James Cowling) by CMU Database Group, generated from the public captions YouTube serves with the video. The transcript has 12,155 words across 1,705 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.