Oh, boy, am I gonna get in trouble with this one... talking about Bad Stuff.
But, sometimes it's good to look at a problem (say, performance) from a different angle. This list actually started as a conversation in the bar, way back in 2001, and I just stumbled on a follow-up email today.
Most of the original points still applied, and with a little cleanup and a few points from the new Capacity Planning whitepaper, here it is... in no particular order...
How To Make SQL Anywhere Slow
- Turn AutoCommit on. Or forget to turn it off when using ODBC, ADO.NET, JDBC, PHP, etc.
- Use 1K or 16K or 32K pages.
- Set ROW_COUNTS to ON so every query gets executed twice.
- Set ISOLATION_LEVEL to 2 or 3.
- Set MAX_PLANS_CACHED to 0 so there's no access plan caching.
- Use SET OPTION instead of SET TEMPORARY OPTION to get all those SYSOPTION changes recorded in the log.
- Set OPTIMIZATION_GOAL to First-row for complex queries, especially when your application really wants all the rows (which it probably does, all of the time).
- Set PREFETCH to OFF when scrolling through a result set in sequence.
- Set PREFETCH to ON or Conditional when doing ABSOLUTE FETCHes randomly in the result set.
- Set QUERY_PLAN_ON_OPEN to ON.
- Set RECOVERY_TIME to 1 minute to force lots of unnecessary checkpoints.
- Set a small cache size.
- Put lots of logic in user-defined functions, like SQL statements using many joins and temporary tables.
- Call user-defined functions in the WHERE clause.
- DROP STATISTICS to make the optimizer stupid; it's DROP OPTIMIZER STATISTICS in Version 5 through 7.
- Code DDL in stored procedures to increase the chances of single-threading.
- Use base tables as temporary tables to get lots of unnecessary transaction log I/O.
- In Version 7 and earlier, create indexes where the first 9 bytes are almost universally the same value.
- Run without a transaction log, thus forcing a checkpoint on every single commit.
- Put the transaction log mirror on the same physical device as the transaction log, to get twice the I/O without any benefit.
- Do joins in the application.
- Move WHERE clause logic into the application.
- Choose inappropriate indexes.
- In Version 6 and earlier, don't put indexes on AUTOINCREMENT columns, thus forcing SELECT MAX() after startup.
- Leave off primary keys so recovery will be slow.
- Try to emulate the query engine by using intermediate tables step-by-step, in procedures and application code.
- INSERT rows with missing values, then UPDATE to fill them in, so you get lots and lots of row splits.
- Don't use wide fetches when fetching large result sets.
- Don't use wide inserts when inserting lots of data.
- Use INSERT or INPUT FROM instead of LOAD TABLE when initially populating a database.
- Use Java in the database.
- Specify redundant CHECK constraints.
- PREPARE the same statement over and over again, every single time it's used.
- Use jConnect instead of the iAnywhere JDBC driver.
- Use Open Client so you can get TDS.
- Create convoys on hot rows and pages, say by making thousands of connections use the same rows in the same tables.
- Send lots of small requests across a high latency network.
- Use a custom key table instead of DEFAULT AUTOINCREMENT so all your inserts are serialized.
Plus: Google says "No results found" for "How To Make Oracle Slow", possibly because Oracle runs slow out of the box (zing! :)
3 comments:
Google now shows one result for "How to Make Oracle Slow". No prizes for guessing where that link goes to though.
My favourite is a real application that fetched all rows from the same query about 10,000 times in around 2 minutes. The app could have been rewritten to only fetch these rows once.
That's a very nice post. We have an old application written in .NET which uses SQL Anywhere 10. Our application has a poorly written function which executes mulitple queries consisting of joins and this function is called inside a loop.
We need to optimize the function. However I noticed that when we changed over to SQL Anywhere 11, it started taking a lot more time than it took with version 10. We even did an unload and reload to change to ver 11 file format.
Any ideas on why Ver 11 is making a slow code even slower? Thanks.
Post a Comment