Latest / CyberSecurity Summary / Oracle Database 11gR2 Performance Tuning Cookbook
Transcript
- 0:00Speaker 1: You know that feeling right, You're using an app, click save,
- 0:02Speaker 1: maybe run a report and it just crawls.
- 0:04Speaker 2: Yeah, or you get that email. The system slow.
- 0:07Speaker 1: Exactly, and if there's an Oracle database behind it, figuring
- 0:10Speaker 1: out why it's slow and crucially how to speed it up. Well,
- 0:14Speaker 1: that's the.
- 0:14Speaker 2: Big challenge, absolutely, and it's usually not just one thing,
- 0:17Speaker 2: is it. It could be the code, the database structure itself,
- 0:20Speaker 2: the servers, the network, even it gets complex.
- 0:23Speaker 1: That's precisely what we're digging into today. We've got some
- 0:26Speaker 1: material specific excerpts from the Oracle Database eleven GR two
- 0:31Speaker 1: Performance Tuning Cookbook.
- 0:32Speaker 2: Ah, the cookbook I like that suggests practical recipes here exactly.
- 0:36Speaker 1: Like solutions you can actually apply to specific problems.
- 0:39Speaker 2: And the authors sound like they've been in the trenches.
- 0:42Speaker 2: Sero Furialo Oracle DBA certified professional across a bunch of technologies.
- 0:46Speaker 1: And advitvdo years with Oracle eight through eleven G Tuning Integration,
- 0:53Speaker 1: now a lead DBA at Amazon.
- 0:55Speaker 2: Apparently, so real world stuff, not just theory.
- 0:58Speaker 1: Right, So our mission for you listening in is to
- 1:02Speaker 1: pull out the core ideas, the main techniques from these sources.
- 1:06Speaker 1: It's like getting a shortcut to their key takeaways.
- 1:08Speaker 2: And like the sources say, there's no magic wand for tuning,
- 1:11Speaker 2: it's about applying the right approach.
- 1:13Speaker 1: Okay, so let's start with the basics. What's the ultimate
- 1:16Speaker 1: goal here? According to this material.
- 1:18Speaker 2: Simple really make applications responsive, cut down that user weight time,
- 1:23Speaker 2: stop the complaining emails.
- 1:25Speaker 1: Makes sense, and critically they stress, this isn't something you
- 1:29Speaker 1: bolt on at the end.
- 1:30Speaker 2: No way. Tuning starts early, ideally like application design phase,
- 1:34Speaker 2: and it keeps going through development into production. It's ongoing,
- 1:39Speaker 2: which leads.
- 1:39Speaker 1: Us to the process they lay out, sort.
- 1:41Speaker 2: Of cycle, right, Yeah, an iterative process. First step, get
- 1:44Speaker 2: a baseline.
- 1:45Speaker 1: Okay, why is that baseline so crucial? Seems obvious, but
- 1:49Speaker 1: let's spill it out.
- 1:50Speaker 2: Well, if you don't know how fast things are now,
- 1:52Speaker 2: how can you tell if your change actually helped. You
- 1:55Speaker 2: need that starting point, that measurement.
- 1:57Speaker 1: A point of comparison exactly.
- 1:59Speaker 2: And the source are clear. It needs to be a
- 2:01Speaker 2: system wide baseline, server, stats, io, network, the database itself,
- 2:07Speaker 2: the application, the whole picture, right.
- 2:09Speaker 1: Not just looking at one tiny piece of a baseline established?
- 2:13Speaker 2: Then what then investigate? Use that system wide view to
- 2:17Speaker 2: hunt down the real bottleneck, where's the actual slowdown happening.
- 2:21Speaker 2: So you form a hypothesis basically, you got it, and
- 2:24Speaker 2: then you assume a solution based on that. And this
- 2:26Speaker 2: is key. You define a specific test case for it.
- 2:29Speaker 1: And a way to back out if it goes wrong.
- 2:31Speaker 2: Absolutely, a rollback plan is essential. Can't make things worse?
- 2:35Speaker 1: Okay, So you implement your change, test it functionally, make
- 2:39Speaker 1: sure it didn't.
- 2:39Speaker 2: Break anything, right, Then you test the performance. Compare it
- 2:42Speaker 2: directly against that baseline you took earlier.
- 2:44Speaker 1: Did it get better?
- 2:45Speaker 2: If yes, brilliant, you might have found your fix.
- 2:48Speaker 1: And if not, or if it oops made things.
- 2:50Speaker 2: Worse, then you iterate, roll back, go back to investigating,
- 2:55Speaker 2: maybe form a different hypothesis, try another solution, keep cycling through.
- 2:58Speaker 1: And the sources mentioned the tools you'd use for this, right, Yeah,
- 3:01Speaker 1: the usual suspects.
- 3:02Speaker 2: Yeah, the core oracle stuff, the data dictionary, those vital
- 3:06Speaker 2: Dynamic performance views, the vviews, plus reporting tools like stats pack, AWR,
- 3:12Speaker 2: ADDM for diagnostics, and of course the alert log and
- 3:16Speaker 2: trace files for digging into specifics. That's where you get
- 3:19Speaker 2: your data.
- 3:19Speaker 1: Okay, process clear, Let's get into the juicy bits. The
- 3:23Speaker 1: key tuning areas from the cookbook. They start with application design.
- 3:27Speaker 2: Makes sense, how the app talks to the database is huge.
- 3:30Speaker 2: First up, connection management.
- 3:32Speaker 1: Ah yeah, The sources point out how lots of online
- 3:35Speaker 1: tutorials show like connecting for every single.
- 3:38Speaker 2: Web page hit, which is just terrible for performance under
- 3:41Speaker 2: any real load.
- 3:42Speaker 1: So what's the recommended way for web apps connection pooling?
- 3:45Speaker 2: Definitely reuse those connections for client server OLTP, maybe middle
- 3:49Speaker 2: tier that manages shared connections.
- 3:51Speaker 1: And the why is pretty simple.
- 3:52Speaker 2: Yeah, setting up a database connection takes time and resources
- 3:56Speaker 2: doing that millions of times. It adds up fast. Reusing
- 3:59Speaker 2: is way way.
- 3:59Speaker 1: To keep Okay. Now, this next one sounds critical. Parsing
- 4:03Speaker 1: and bind variables. The sources really emphasize this.
- 4:05Speaker 2: Oh absolutely, this is a big one. They talk about
- 4:08Speaker 2: hard parsing versus soft parsing.
- 4:10Speaker 1: Right, hard parses oracle figures everything out and scratch syntax, permissions,
- 4:14Speaker 1: the execution.
- 4:15Speaker 2: Plan exactly every single time. Soft parses reusing a plan
- 4:18Speaker 2: that's already in the.
- 4:19Speaker 1: Cash much faster, and the magic ingredient for soft parsing,
- 4:23Speaker 1: especially when you run the same type of query over
- 4:25Speaker 1: and over with different values, is bind variables.
- 4:28Speaker 2: That's the key. If your app builds SQL with literal
- 4:32Speaker 2: values like where use radicals one twenty three and then
- 4:35Speaker 2: where use ridicules four fifty six.
- 4:37Speaker 1: Oracle sees two totally different queries hard parse both right.
- 4:40Speaker 2: But if you use a bind variable like where use
- 4:43Speaker 2: radicles some value, Oracle sees the same sequel structure. It
- 4:47Speaker 2: can reuse the plan generated for the first value when
- 4:50Speaker 2: the second value comes along. Soft parse huge win.
- 4:53Speaker 1: The concept in the sources comparing Java execution times without
- 4:57Speaker 1: and with prepared statements which use binds really drives that home,
- 5:01Speaker 1: doesn't it. The performance difference is massive, It really is.
- 5:03Speaker 2: They even talk about aiming for a library cash hit ratio.
- 5:06Speaker 2: You check them into a library catch of like zero
- 5:08Speaker 2: point nine nine nine nine one and busy OLTP systems
- 5:11Speaker 2: almost perfect reuse.
- 5:12Speaker 1: Wow. And there's a security angle too.
- 5:14Speaker 2: Big time buying variables are your primary defense against SQL injection,
- 5:18Speaker 2: so faster and safer win win.
- 5:20Speaker 1: And plcql handles this automatically for static SQL.
- 5:23Speaker 2: Yep, the plcql engine is smart about that. Good news.
- 5:25Speaker 1: There another application design tip mentioned, fewer round trips to
- 5:30Speaker 1: the database.
- 5:30Speaker 2: Yeah, especially over networks. Each trip has latency. Better to
- 5:34Speaker 2: bundle operations.
- 5:35Speaker 1: If you can, like using stored procedures or packages to
- 5:38Speaker 1: do several things in one call.
- 5:40Speaker 2: Exactly reduce the chatter. Materialized views also get a.
- 5:44Speaker 1: Mention ah precalculated results good for data warehouses.
- 5:48Speaker 2: Maybe yeah, can speed up complex queries, but the sources
- 5:52Speaker 2: give a strong warning avoid refresh on commit for MVS
- 5:56Speaker 2: in OLTP.
- 5:57Speaker 1: Why is that?
- 5:58Speaker 2: Because that refresh happens to your commit, it slows down
- 6:01Speaker 2: every transaction that modifies the base tables. Bad for response time.
- 6:05Speaker 1: Okay, got it. Let's shift from the application code to
- 6:09Speaker 1: how the data is actually stored. Road chaining and migration.
- 6:12Speaker 1: That's technical.
- 6:13Speaker 2: It is a bit. Think of a data block as
- 6:15Speaker 2: a page. Road Chaining is when one row is just
- 6:19Speaker 2: too big to fit on a single page, so it
- 6:20Speaker 2: gets split across multiple blocks.
- 6:22Speaker 1: Okay, and migration.
- 6:24Speaker 2: Migration is when a row fix initially, but then you
- 6:26Speaker 2: update it, it grows and there's no more space left
- 6:29Speaker 2: in that block, so oracle moves the whole row to
- 6:33Speaker 2: a new block and leaves a pointer behind.
- 6:35Speaker 1: And both are bad because extra.
- 6:37Speaker 2: Io to read that one chained row, you need to
- 6:40Speaker 2: read multiple blocks. For a migrated row, you read the
- 6:42Speaker 2: original block just to find the pointer than the new block.
- 6:45Speaker 2: More work for the database.
- 6:47Speaker 1: How do you find these sources?
- 6:48Speaker 2: Mention analyzed table list, chained rows or using a script
- 6:52Speaker 2: called ultchain dot squyel and fixing it for chaining. Maybe
- 6:57Speaker 2: a larger block size for that table, though that has
- 6:59Speaker 2: other implications for migration. Adjusting pct free to leave more
- 7:03Speaker 2: empty space in blocks for rows to grow into during updates.
- 7:06Speaker 1: But using multiple block sizes can make buffer cash tuning tricky.
- 7:10Speaker 2: Right yeah, as complexity. We'll get to the buffer cash later.
- 7:12Speaker 1: What about a lobe's large objects blos clos.
- 7:17Speaker 2: They're often stored differently, especially if they're big like over
- 7:20Speaker 2: four k or so, often offline or out of row,
- 7:23Speaker 2: separate from the main table data.
- 7:24Speaker 1: And you can save space with deduplication or compression.
- 7:27Speaker 2: YEP techniques exist. DBMS space space usage helps check how
- 7:32Speaker 2: much space they're using.
- 7:33Speaker 1: Okay, Clusters index and hash.
- 7:36Speaker 2: These physically group rows from different tables together in the
- 7:39Speaker 2: same blocks if they share common columns and are often
- 7:42Speaker 2: joined on those columns.
- 7:43Speaker 1: So if you query via that cluster key, the data
- 7:46Speaker 1: is already co located. Faster joins.
- 7:49Speaker 2: That's the idea avoids oracle having to jump around fetching
- 7:52Speaker 2: blocks from different tables. How you load the data into
- 7:55Speaker 2: the cluster initially matters, though.
- 7:57Speaker 1: Makes sense, all right, indexes, This feels fundamentally oh it.
- 7:59Speaker 2: Is avoiding full table scans on big tables, and OLTP
- 8:03Speaker 2: is usually priority number one. Indexes are how you do that.
- 8:06Speaker 2: They help Oracle find rows quickly.
- 8:08Speaker 1: Standard B tree indexes, bitmap indexes. What about multi column indexes?
- 8:12Speaker 2: The order matters critically. If your query wear clause uses
- 8:15Speaker 2: the first column the leading edge of a multi column index,
- 8:19Speaker 2: Oracle can efficiently scan just a relevant range index range scan.
- 8:23Speaker 1: But if you only query on say the second column,
- 8:27Speaker 1: it might.
- 8:28Speaker 2: Still use the index with an index fast full scan
- 8:31Speaker 2: which reads the entire index, not just a range. Faster
- 8:34Speaker 2: than a full table scan maybe, but not as good
- 8:36Speaker 2: as a range scan, and it doesn't return rows sorted
- 8:40Speaker 2: by the index key.
- 8:41Speaker 1: Function based indexes.
- 8:42Speaker 2: Descending indexes useful for avoiding explicit sort operations. Sometimes, if
- 8:47Speaker 2: you index the result of a function or index in
- 8:50Speaker 2: descending order, Oracle might be able to skip a sort
- 8:53Speaker 2: step for order by or group buy.
- 8:55Speaker 1: But indexes aren't always used even if they exist.
- 8:58Speaker 2: Right the sources list common reach using not equal or
- 9:02Speaker 2: applying a function to an index column unless it's a
- 9:04Speaker 2: matching function based index searching for NL's B tree. Indexes
- 9:08Speaker 2: don't store entries for all nul.
- 9:10Speaker 1: Keys, ah okay, And if the query needs columns not
- 9:13Speaker 1: in the index.
- 9:14Speaker 2: Then oracle has to do a table access by rowd
- 9:16Speaker 2: for every row found in the index. On small tables,
- 9:19Speaker 2: a full scan might actually be cheaper than thousands of
- 9:22Speaker 2: those individual table lookups.
- 9:23Speaker 1: Six. Rebuilding and compression.
- 9:25Speaker 2: Why rebuild if stats suggests it's become inefficient or fragmented
- 9:29Speaker 2: The sources mentioned looking at ratios like deleted leafros versus
- 9:33Speaker 2: total leaf ros, delf, frous frows, INDEBA indexes or debanded
- 9:37Speaker 2: statistics if it's high maybe two, or if leaf ros
- 9:40Speaker 2: lfro is much lower than leafblocks lfblks, or if the
- 9:45Speaker 2: index height gets to four or more. These are just indicators, though,
- 9:49Speaker 2: and you can rebuild online yep lets users keep working DML,
- 9:53Speaker 2: but the rebuild takes longer. Offline is faster, but locks
- 9:57Speaker 2: the table. You can also gather fresh stats during the
- 9:59Speaker 2: re build. Compression save space by storing common prefix values
- 10:03Speaker 2: only once per index block. Fewer blocks means faster reads.
- 10:07Speaker 2: Use the compressed keyword maybe specifying how many prefixed callers
- 10:10Speaker 2: to compress.
- 10:11Speaker 1: Reverse key indexes sound specific, very.
- 10:13Speaker 2: Specific use case. Think sequence generated primary keys and high
- 10:17Speaker 2: volume inserts.
- 10:18Speaker 1: Right, because normally all inserts go to the right end of.
- 10:20Speaker 2: The INDEXX actually causes contention on those last few index blocks.
- 10:24Speaker 2: A reverse key index flips the key bytes around a
- 10:26Speaker 2: one to twenty three becomes three twenty one. Spreading inserts
- 10:29Speaker 2: across the whole index structure reduces that hot block contention.
- 10:33Speaker 2: Range scans become inefficient because the keys aren't stored sequentially anymore.
- 10:37Speaker 1: Okay. Bitmap indexes good for low cardinality columns.
- 10:41Speaker 2: Yes, columns with few distinct values like gender status flags.
- 10:45Speaker 2: Great in data warehouses on large tables, very efficient space
- 10:49Speaker 2: wise and for certain queries.
- 10:51Speaker 1: But not for OLTP.
- 10:53Speaker 2: Why again, locking If you update one row covered by
- 10:57Speaker 2: a bitmap index, segment oracle locks that entire segment in
- 11:00Speaker 2: OLTP with lots of concurrent updates. This causes massive bottlenecks.
- 11:04Speaker 2: Everyone waits. They also index NAL's unlike B.
- 11:07Speaker 1: Trees index organized tables IoTs.
- 11:10Speaker 2: Here the table is the index data is stored within
- 11:13Speaker 2: the primary key B tree.
- 11:14Speaker 1: Structure, and things like compress, including overflow control, how that
- 11:18Speaker 1: data is stored within the.
- 11:19Speaker 2: Index precisely, how non key columns fit, what happens if
- 11:22Speaker 2: rows get too big, et cetera.
- 11:23Speaker 1: Partitioning big topic, major benefit partition pruning.
- 11:27Speaker 2: If your table is partitioned, say by date range, and
- 11:30Speaker 2: your query has a wear clause on that date, Oracle
- 11:33Speaker 2: only needs to scan the relevant partitions. Huge performance gain
- 11:36Speaker 2: for large tables also helps with manageability.
- 11:38Speaker 1: All right, let's switch to optimizing the actual SQL code
- 11:42Speaker 1: avoiding full table scans again.
- 11:44Speaker 2: Yeah, it's a recurring theme for large OLTP tables, though
- 11:46Speaker 2: again for small tables, FDS can be fine, even faster sometimes.
- 11:50Speaker 1: And the high water mark HWM concept comes up.
- 11:52Speaker 2: Here, right. Think of it as the high tide mark
- 11:55Speaker 2: in the table, and FTS reads every block below that mark,
- 11:58Speaker 2: even if they're now empty after deletes.
- 12:00Speaker 1: So deleting data doesn't lower the HWM.
- 12:03Speaker 2: Noope, only ways mentioned to reset it are truncate, alter
- 12:07Speaker 2: table move or an export drop import altertable deallocate unused
- 12:12Speaker 2: just free space above the HWM.
- 12:14Speaker 1: Okay, this next one feels like a core Oracle principle
- 12:17Speaker 1: array processing and bulk operations doing things in sets, not
- 12:21Speaker 1: row by row.
- 12:21Speaker 2: Absolutely fundamental the sources. Contrast row by row processing in
- 12:25Speaker 2: loops often called row at a time or slow by
- 12:27Speaker 2: slow processing with using bulk collect to fetch many rows
- 12:30Speaker 2: into plsuple rays at once and FOURAL to insert, update,
- 12:34Speaker 2: or delete many rows from an array in a single database.
- 12:37Speaker 1: Call, and the performance difference is dramatic.
- 12:40Speaker 2: Huge orders of magnitude faster. Typically The examples shown really
- 12:44Speaker 2: highlight this.
- 12:45Speaker 1: They mentioned the limit clause with these bulk operations. Why
- 12:48Speaker 1: use that? If processing all at once is.
- 12:50Speaker 2: Fastest memory management? Bulk collect and FOURAL use PGA memory.
- 12:56Speaker 2: If you try to process millions of rows without limit,
- 12:59Speaker 2: you could blow out your PGA using limit one hundred
- 13:02Speaker 2: or limit one thousand processes in manageable chunks, preventing memory
- 13:05Speaker 2: errors while still being vastly faster than row biro.
- 13:09Speaker 1: Smart optimizing joins. Oracle has different ways to join tables.
- 13:13Speaker 2: YEP, nested loops, Sort, merge, hash join are the main
- 13:16Speaker 2: ones mentioned.
- 13:17Speaker 1: When does it prefer each Roughly.
- 13:19Speaker 2: Nested loops often works well if there's a good index
- 13:21Speaker 2: on the join column of the inner table and not
- 13:23Speaker 2: too many rows are involved. Sort merge sorts both inputs first,
- 13:28Speaker 2: then merges good for non equi joints doesn't need indexes
- 13:31Speaker 2: but uses sort memory CPU hash join builds a hash
- 13:34Speaker 2: table and memory on the smaller input. Often the go
- 13:36Speaker 2: to when nested loops isn't efficient, needs memory.
- 13:39Speaker 1: Subqueries in versus exists not in versus not.
- 13:43Speaker 2: Exists sources mention. There are differences in how they handle
- 13:45Speaker 2: nlls and potential performance variations. Worth understanding the nuances for
- 13:49Speaker 2: your specific query and tracing.
- 13:52Speaker 1: SQL trace and tkprof central.
- 13:55Speaker 2: Tools absolutely vital for understanding what a query is really doing.
- 14:00Speaker 2: TKPRF formats the trace file and shows you execution counts,
- 14:03Speaker 2: CPU time, a lapse time ioreads disc versus memory rose
- 14:08Speaker 2: processed all the details you need to diagnose where the
- 14:11Speaker 2: time is actually going.
- 14:12Speaker 1: Okay, let's talk sorts order by group by distinct. They
- 14:16Speaker 1: all involve sorting right.
- 14:17Speaker 2: Often yes for some joint methods. Key difference is in
- 14:21Speaker 2: memory versus on disc sorts.
- 14:22Speaker 1: Your memory is faster.
- 14:24Speaker 2: Much faster happens in the PGA on disc sorts happen
- 14:27Speaker 2: when the data to be sorted is too big for
- 14:29Speaker 2: the available PGA, so oracle spills it to the temporary
- 14:32Speaker 2: table space slower due to disc io. How do you
- 14:35Speaker 2: monitor this ve stat has sort counters memory versus desk.
- 14:39Speaker 2: Execution plans might show temp speary. Tuning often involves sizing
- 14:43Speaker 2: the PGA appropriately.
- 14:44Speaker 1: And VPGA target advice helps with that PGA sizing.
- 14:47Speaker 2: Yeah, it's a great advisor. View simulates different PGA sizes
- 14:50Speaker 2: and estimates the impact on sorts and hash joins helps
- 14:53Speaker 2: you set pgeggor get target.
- 14:55Speaker 1: But the best sort is no sort at all exactly.
- 14:58Speaker 2: If you have the right index, oracle might be able
- 15:01Speaker 2: to read the data in the order needed for an
- 15:03Speaker 2: order buy directly from the index index full scan or
- 15:07Speaker 2: satisfy a group by or distinct using an index index
- 15:11Speaker 2: fast full scan maybe with a sort unique potentially avoided
- 15:14Speaker 2: or made faster saves a whole processing step.
- 15:17Speaker 1: Analytical functions like rank denser rank good for.
- 15:21Speaker 2: Top then yeah, useful for that kind of analysis. The
- 15:24Speaker 2: source example shows how rank handles ties might give you
- 15:27Speaker 2: more than n rows if there are ties at the boundary.
- 15:29Speaker 1: Aggregates. Min max count indexes.
- 15:32Speaker 2: Help here too, definitely. For minimax an index on the column,
- 15:35Speaker 2: let's oracle just grab the first or last index entry,
- 15:37Speaker 2: avoiding a full scan for account. There's a cool optimization
- 15:41Speaker 2: mentioned If a suitable bitmap index exists on a non
- 15:44Speaker 2: Knoll column, oracle might use that for a very fast count.
- 15:47Speaker 1: And troubleshooting temspace to monitoring usage pretty much.
- 15:52Speaker 2: Views like vtemspace, hutter, vsort segment, vtemp file help you
- 15:55Speaker 2: see who's using temspace and if you're running out, and
- 15:58Speaker 2: how to create an assigned t table spaces.
- 16:00Speaker 1: Let's loop back to PLCQ optimization bulk processing again.
- 16:04Speaker 2: Yep, Bellki collect and foural same principle. Massive gains over
- 16:09Speaker 2: roebiro loops inside plcql two can't stress that enough.
- 16:12Speaker 1: Short circuit if statements, small tweaks.
- 16:15Speaker 2: Yeah, In if condition one and D condition two, put
- 16:18Speaker 2: the one most likely to be false first. In if
- 16:21Speaker 2: condition one or R condition two, put the one most
- 16:24Speaker 2: likely to be true first, might save evaluating the second conditions.
- 16:28Speaker 1: Sometimes recursion generally avoid for performance critical stuff.
- 16:32Speaker 2: That's the advice. Each recursive call eats PGA memory for
- 16:36Speaker 2: its state. Deep recursion can get expensive. Fast iterative loops
- 16:40Speaker 2: are usually much more efficient in plseql. The factorial example
- 16:44Speaker 2: comparison shows.
- 16:45Speaker 1: This native compilation PLCQL code type equals in native.
- 16:49Speaker 2: Compiles PLSQL to machine code instead of interpreted bytecode can
- 16:52Speaker 2: give a speed boost, as the binomial coefficient example suggests,
- 16:55Speaker 2: but compilation takes longer and uses more resources.
- 16:58Speaker 1: PLCQL result cache, similar.
- 17:00Speaker 2: To the SQL yeah result cash clause on a function
- 17:02Speaker 2: cash's results based on input parameters. If called again with
- 17:05Speaker 2: the same inputs, oracle returns the cash result without re
- 17:08Speaker 2: running the function. Need relycen if it depends on tables inlining.
- 17:12Speaker 1: Compiling called code directly into the caller.
- 17:14Speaker 2: Rate reduces function call overhead. PREGMA inline or setting PLSKO
- 17:19Speaker 2: optimized level to three enables.
- 17:20Speaker 1: This virtual columns. This eleven G feature sounds interesting.
- 17:24Speaker 2: It is cool define a column based on an expression
- 17:27Speaker 2: of other columns, but the data isn't stored physically.
- 17:30Speaker 1: A digwin, you.
- 17:30Speaker 2: Can index or partition based on that calculated value without
- 17:34Speaker 2: needing a trigger to maintain it. Triggers can be major
- 17:37Speaker 2: performance killers. The gross capital example in the loan's table
- 17:40Speaker 2: makes this really clear.
- 17:42Speaker 1: Okay, shifting again improving the oracle optimizer itself. How it
- 17:46Speaker 1: works briefly parses.
- 17:47Speaker 2: The sequel, optimizes, picks the plan using costs, generates the
- 17:51Speaker 2: row source executes the plan. The cost based optimizer CBO
- 17:56Speaker 2: uses statistics, object info and system parameters to SIP to
- 18:00Speaker 2: make the cost of different plans and pick the cheapest optimizer.
- 18:03Speaker 1: Hints suggestions not commands exactly.
- 18:06Speaker 2: You put them in comments plus it inta They guide
- 18:09Speaker 2: the optimizer, but it might ignore them if they're wrong
- 18:12Speaker 2: or conflict, or follow them even if the resulting plan
- 18:15Speaker 2: is bad.
- 18:15Speaker 1: So always verify the plan after adding a hint.
- 18:18Speaker 2: Absolutely critical. Don't assume the hint worked or helped without
- 18:22Speaker 2: checking the explained plan or vesicle plan.
- 18:25Speaker 1: And the foundation for good CBO decisions is statistics. YEP.
- 18:29Speaker 2: Accurate, up to date statistics are essential. DBMS stats package
- 18:33Speaker 2: gather procedures is the way to collect them. Dynamic sampling
- 18:36Speaker 2: is mentioned as a fallback. If stats are missing. You
- 18:39Speaker 2: can lock stats, view history restore old stats too.
- 18:43Speaker 1: Histograms needed when data is.
- 18:45Speaker 2: Skewed right when values aren't evenly distributed. Standard stats assume
- 18:50Speaker 2: even distribution, which can lead to bad cardinality estimates. Histograms
- 18:54Speaker 2: give the CEO more detail about actual data distribution, leading
- 18:57Speaker 2: to better plans created via DBMS stats.
- 19:00Speaker 1: Pland stability plans. Changing unexpectedly is a pain.
- 19:03Speaker 2: Tools. Two main ones mentioned stored outlines are the older
- 19:07Speaker 2: way They lock down a specific plan stable but rigid,
- 19:10Speaker 2: won't adapt if a better plan becomes available later.
- 19:13Speaker 1: That's SQL baselines. The eleven G approach more flexible.
- 19:16Speaker 2: They capture known good plans but can evolve. You can
- 19:19Speaker 2: test new plans generated by the optimizer and if verified
- 19:22Speaker 2: to be better using DBMSPM evlvescal plan baseline, the baseline
- 19:27Speaker 2: can accept the new improved plan. Stability plus adaptation.
- 19:31Speaker 1: Adaptive cursor sharing tackles bind variable.
- 19:34Speaker 2: Peaking exactly that issue where the plan chosen based on
- 19:38Speaker 2: the first bind value scene isn't good for later values. ACS.
- 19:41Speaker 2: Let's oracle detect this and maintain multiple plans for the
- 19:44Speaker 2: same sequel, using the best one based on the range
- 19:47Speaker 2: of bind values encountered.
- 19:48Speaker 1: Pretty smart and automated tuning. SQL tuning Visor SQL tuning
- 19:52Speaker 1: sets yeah.
- 19:53Speaker 2: Tools to help automate the process. SQL tuning sets STS
- 19:56Speaker 2: are just collections of SQL statements you want to analyze
- 19:59Speaker 2: the SEQLE Tuning Advisor can analyze single queries a WR
- 20:02Speaker 2: data or an sts and give recommendations new stats, profiles, hints, indexes, maybe.
- 20:07Speaker 1: Okay, some other optimization odds and ends. SQL result cash.
- 20:10Speaker 2: Again right using the plus result cash hint on a
- 20:12Speaker 2: query cash is the actual results set in memory SGA
- 20:16Speaker 2: or client. If the exact same query runs again, boom,
- 20:18Speaker 2: instant results.
- 20:19Speaker 1: Parallel SQL for multi core systems.
- 20:21Speaker 2: YEP plus parallel hint breaks down query operations to run
- 20:25Speaker 2: concurrently can speed things up dramatically on the right hardware,
- 20:28Speaker 2: but the sources warn it can hurt performance on single
- 20:31Speaker 2: CPU machines, or if you don't have enough resources.
- 20:33Speaker 1: Direct path inserts insert plus appendres.
- 20:37Speaker 2: Faster for bulkloads, skips the buffer. Cash writes directly to
- 20:40Speaker 2: data files above the HWM trade offs can invalidate indexes
- 20:45Speaker 2: need rebuild might be slower if IO is already saturated,
- 20:48Speaker 2: data isn't immediately available in the buffer.
- 20:50Speaker 1: Cash for reads create table is select cts uses direct
- 20:55Speaker 1: path implicitly.
- 20:56Speaker 2: Usually yes, efficient way to copy large amounts of data, and.
- 20:59Speaker 1: Schooloader data pump direct path mode there too, YEP.
- 21:02Speaker 2: Similar concept for loading external data much faster than conventional path,
- 21:06Speaker 2: which goes through the buffer. Cash and SQL air.
- 21:08Speaker 1: And dropping indexes before a huge load, then rebuilding Yeah
- 21:12Speaker 1: faster sometimes often yes.
- 21:14Speaker 2: The overhead of maintaining indexes during millions of inserts can
- 21:17Speaker 2: be higher than a drop load and recreate.
- 21:19Speaker 1: Cycle all right memory tuning SGA versus.
- 21:22Speaker 2: PGA SGA system global area shared by all processes PGA
- 21:27Speaker 2: program global area private to each process, v process vmstat,
- 21:32Speaker 2: VISA stat help monitor.
- 21:33Speaker 1: Shared pool, library cash crucial for SQL.
- 21:35Speaker 2: Reuse absolutely stores parsed SQL pl single high hit ratio
- 21:40Speaker 2: and VILO library cache is key low ratio often points
- 21:43Speaker 2: back to no bind.
- 21:44Speaker 1: Variables really vicious cycle.
- 21:46Speaker 2: You can use visila a pl air ficile plan to
- 21:48Speaker 2: see what's cashed DDMS share pool keep to pin critical objects.
- 21:52Speaker 2: There's also the reserved pool for large allocations and the
- 21:55Speaker 2: dictionary cash for metadata EGA.
- 21:57Speaker 1: Use for sorts hash joints tuned via p egercate.
- 22:00Speaker 2: Target primarily yes. Vckt Argita advice is your best friend
- 22:04Speaker 2: for sizing that UGA is part of PGA holding session
- 22:07Speaker 2: state affected by cursor parameters like open cursors.
- 22:10Speaker 1: For cash cash is data blocks some disc.
- 22:12Speaker 2: YEP reduces physical io. V clabkh advice helps size it
- 22:16Speaker 2: calculate the hit ratio logical reads versus physical reads from stats.
- 22:20Speaker 2: Multiple block sizes can complicate things.
- 22:21Speaker 1: And the keep in recycled pools special.
- 22:23Speaker 2: Purpose keep is for small frequently used objects you want
- 22:26Speaker 2: to guarantee stay cached or maybe small fts tables. Recycle
- 22:31Speaker 2: is for large objects you access once and don't want
- 22:34Speaker 2: polluting the main cache assigned objects via alter table.
- 22:37Speaker 1: Index storage tuning. IO raid levels matter big time.
- 22:41Speaker 2: Sources say RAY ten zero plus one is best for
- 22:44Speaker 2: performance but costs more. Rade five has a right penalty,
- 22:47Speaker 2: bad for redo logs and undo.
- 22:49Speaker 1: Asynchronous io allows overlapping IO requests.
- 22:53Speaker 2: Yes helps DVWN and LGWR make better use of IO bandwidth,
- 22:57Speaker 2: improving throughput and scalability. Less way waiting for iocompletion.
- 23:01Speaker 1: Checkpoints need to monitor them, crucial for recovery.
- 23:04Speaker 2: Alert log and VC stats show activity if checkpoints started
- 23:08Speaker 2: far ex seeds completed. Redo logs might be switching too often,
- 23:11Speaker 2: probably because they're too small.
- 23:12Speaker 1: Relugs tuning involves monitoring switches be like history and weights
- 23:16Speaker 1: v sense of N four log file parallel.
- 23:18Speaker 2: Right exactly bottlenecks there can really slow things down fast.
- 23:21Speaker 1: Big area tuning contention users waiting on each.
- 23:24Speaker 2: Other locks are a common cost. Row locks, TX table locks,
- 23:28Speaker 2: tm V lock helps find who's blocking whom. The example
- 23:33Speaker 2: of two sessions trying to update the same row makes
- 23:36Speaker 2: it clear.
- 23:36Speaker 1: Deadlocks The nasty circular weight.
- 23:39Speaker 2: YEP database de texts IT kills one transaction logs IT
- 23:42Speaker 2: You find details in trace files and the alert.
- 23:45Speaker 1: Log transaction design.
- 23:47Speaker 2: Commit frequency matters a lot too frequent commits ad overhead two,
- 23:51Speaker 2: infrequent holds, locks, longer increases, undo risks RI zero one
- 23:56Speaker 2: five to five to five snapshot too old. Long transactions
- 23:59Speaker 2: are generally tough on the system.
- 24:01Speaker 1: Latches, low level memory.
- 24:02Speaker 2: Locks, very fast short duration locks. Protecting SGA structures, monitor
- 24:06Speaker 2: weights and contention using vlbcch vlatched children, OA reports latch
- 24:11Speaker 2: free events.
- 24:12Speaker 1: But the key takeaway for latches there's symptoms.
- 24:14Speaker 2: High lashed contention means something else is wrong, usually bad SQL,
- 24:17Speaker 2: lack of bind variables, undersized caches. You tune the cause,
- 24:21Speaker 2: not the latch itself, and.
- 24:22Speaker 1: Library cash latches directly link back to.
- 24:25Speaker 2: Not using bind variables. All that hard parsing causes contention
- 24:28Speaker 2: for latches protecting the library cash. It all ties together.
- 24:32Speaker 1: Wow. Okay, that was definitely deep dive from application code
- 24:36Speaker 1: storage SQL, PLSEQL memory io all the way to contention.
- 24:42Speaker 2: It really covers the spectrum, doesn't it, And it hammers
- 24:44Speaker 2: home that cookbook idea. Lots of different potential issues lots
- 24:48Speaker 2: of different recipes or techniques to address them, and.
- 24:51Speaker 1: The absolute need for that structured process. Baseline, investigate, hypothesize, test, measure, iterate.
- 25:00Speaker 1: You can't just guess, no guessing.
- 25:02Speaker 2: You need to diagnose the specific problem first, use the tools,
- 25:05Speaker 2: look under the hood, understand the why.
- 25:07Speaker 1: So maybe a final thought for you, the listener, based
- 25:10Speaker 1: on all this, Yeah, just how incredibly interconnected everything is
- 25:13Speaker 1: inside Oracle. Yeah, you change application code with bind variables
- 25:16Speaker 1: and suddenly library cash latch contention drops. You choose the
- 25:19Speaker 1: wrong raid level and redo log rights become a bottleneck.
- 25:23Speaker 1: You size memory incorrectly and sort spill to disc slowing
- 25:26Speaker 1: everything down.
- 25:27Speaker 2: It's all linked. Understanding those connections, how turning one area
- 25:30Speaker 2: can impact another. That's maybe the real key takeaway from
- 25:32Speaker 2: this material. It's thinking about the whole system.
- 25:35Speaker 1: Absolutely well, thanks for joining us on this exploration of
- 25:38Speaker 1: Oracle database performance tuning, gated by these cookbook excerpts hopefully
- 25:43Speaker 1: gives you a better framework for tackling those slowdowns.