1 / 45

The Thinking Person’s Guide to Data Warehouse Design Robin Schumacher VP Products Calpont

Learn how to build a logical and physical design, monitor and tune the design, and make key decisions for a successful data warehouse. Explore the benefits of using a modeling tool, considerations for logical design, and the pros and cons of manual partitioning. Discover the best approach for scaling, whether to use SQL or NoSQL, and the advantages of row or column-based databases. Explore the options for storage engines and learn about the potential of NoSQL. Stay ahead in data warehouse design with this comprehensive guide.

Télécharger la présentation

The Thinking Person’s Guide to Data Warehouse Design Robin Schumacher VP Products Calpont

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Thinking Person’s Guide to Data Warehouse Design Robin Schumacher VP Products Calpont

  2. Agenda Building a logical design Transitioning to a physical design Monitoring and tuning the design

  3. Building a logical design

  4. Why care about design…?

  5. What is the key component for success? * In other words, what you do with your MySQL Server – in terms of physical design, schema design, and performance design – will be the biggest factor on whether a BI system hits the mark… * Philip Russom, “Next Generation Data Warehouse Platforms”, TDWI, 2009.

  6. First – get/use a modeling tool

  7. The logical design for OLTP

  8. Simple reporting databases End Users Application Servers Read Shard One Reporting Database OLTP Database ETL Replication Just use the same design on a different box…

  9. Horror story number one…

  10. The logical design for analytics/data warehousing

  11. Logical Design Considerations • Datatypes are more generally defined, not directed toward a database engine • Entities aren’t designed for performance necessarily • Redundancy is avoided, but simplicity is still a goal • Bottom line: you want to make sure your data is correctly represented and is easily understood (new class of user today)

  12. Manual horizontal partitioning Modeling technique to overcome large data volumes

  13. Manual Vertical Partitioning Modeling technique to overcome wide tables/rows

  14. Pro’s/con’s to manual partitioning Pro’s • Less I/O if design holds up • Easy to prune obsolete data • Possibly less object contention Con’s • More tables to manage • More referential integrity to manage • More indexes to manage • Joins oftentimes needed to accomplish query requests • Oftentimes, a redesign is needed because the rows / columns you thought you’d be accessing together change; it’s hard to predict ad-hoc query traffic

  15. The bottom line on logical modeling • Use a modeling tool to capture your designs • Do not utilize a third-normal form design for analytics; keep it simple and understandable • Manual partitioning is OK in some cases, but,.. • Let the database engine do the work for you

  16. Transitioning to a physical design

  17. How to scale…? SQL or NoSQL…? Should I worry about High availability…? Index or no…? Is sharding a good idea…? How should I partition my data…? Row or Column database…?

  18. General list of top BI database design decisions • General architecture / data orientation • Storage engine selection • Physical table/Index partitioning • Indexing creation and placement • Optimizing data loads

  19. Divide & conquer is the best approach • Whether you choose to go NoSQL, Shard with normal or special MySQL engines, use MPP storage engines, or something similar, divide & conquer is your best friend • You can scale-up and divide & conquer to a point, but you will hit disk, memory, or other limitations • Scaling up and out is the best future proof methodology

  20. Divide & conquer via sharding

  21. What technologies you should be looking at * * Philip Russom, “Next Generation Data Warehouse Platforms”, TDWI, 2009.

  22. Row or column-based engine?

  23. Column vs. row orientation A column-oriented architecture looks the same on the surface, but stores data differently than legacy/row-based databases…

  24. Example: InfiniDB vs. “Leading” row DB InfiniDB takes up 22% less space InfiniDB loaded data 22% faster InfiniDB total query times were 65% less InfiniDB average query times were 59% less Notice not only are the queries faster, but also more predictable * Tests run on standalone machine: 16 CPU, 16GB RAM, CentOS 5.4 with 2TB of raw data

  25. Why not use both…? • You can create a hybrid system where you use row-based tables and column-based tables in the same instance and same database • Use InnoDB for OLTP or MyISAM for certain read operations • Use column-based tables for analytics, data marts, or warehouses • You can scale out with column tables and use row-based tables locally

  26. Why not use both…?

  27. Most used DW Storage engines internal to MySQL MyISAM • High-speed query/insert engine • Non-transactional, table locking • Good for data marts, small warehouses Archive • Compresses data by up to 80% • Fastest for data loads • Only allows inserts/selects • Good for seldom accessed data Memory • Main memory tables • Good for small dimension tables • B-tree and hash indexes CSV Also:Merge for pre-5.1 partitioning • Comma separated values • Allows both flat file access and editing as well as SQL query/DML • Allows instantaneous data loads

  28. What about NoSQL options? • Standard model is not relational • Typically don’t use SQL to access the data • Take up more space than column databases • Lack special optimizers / features to reduce I/O • Really are row-oriented architectures that store data in ‘column families, which are expected to be accessed together (remember logical vertical partitioning?) Individual columns cannot be accessed independently • Will be faster with individual insert and delete operations • Will normally be faster with single row requests • Will lag in typical analytic / data warehouse use cases

  29. Partitioning – not ‘if’ but ‘how’ mysql> CREATE TABLE part_tab -> ( c1 int ,c2 varchar(30) ,c3 date ) -> PARTITION BY RANGE (year(c3)) (PARTITION p0 VALUES LESS THAN (1995), -> PARTITION p1 VALUES LESS THAN (1996) , PARTITION p2 VALUES LESS THAN (1997) , -> PARTITION p3 VALUES LESS THAN (1998) , PARTITION p4 VALUES LESS THAN (1999) , -> PARTITION p5 VALUES LESS THAN (2000) , PARTITION p6 VALUES LESS THAN (2001) , -> PARTITION p7 VALUES LESS THAN (2002) , PARTITION p8 VALUES LESS THAN (2003) , -> PARTITION p9 VALUES LESS THAN (2004) , PARTITION p10 VALUES LESS THAN (2010), -> PARTITION p11 VALUES LESS THAN MAXVALUE ); mysql> create table no_part_tab (c1 int,c2 varchar(30),c3 date); *** Load 8 million rows of data into each table *** mysql> select count(*) from no_part_tab where c3 > date '1995-01-01' and c3 < date '1995-12-31'; +----------+ | count(*) | +----------+ | 795181 | +----------+ 1 row in set (38.30 sec) mysql> select count(*) from part_tab where c3 > date '1995-01-01' and c3 < date '1995-12-31'; +----------+ | count(*) | +----------+ | 795181 | +----------+ 1 row in set (3.88 sec) 90% Response Time Reduction

  30. Partitioning – Stripe your Partitions CREATE TABLE T1 (col1 INT, col2 CHAR(5), col3 DATE) ENGINE=MYISAM PARTITION BY HASH(col1) ( PARTITION P1 DATA DIRECTORY = '/appdata1/data', PARTITION P2 DATA DIRECTORY = '/appdata2/data', PARTITION P3 DATA DIRECTORY = '/appdata3/data’, PARTITION P4 DATA DIRECTORY = '/appdata4/data’ ); Note that striping only works for some engines (e.g. MyISAM, Archive) and for only certain operating systems (e.g. the option is ignored on Windows). You can use the REORGANIZE PARTITION command to move current partitions to new devices.

  31. Partitioning – Smart Data Pruning Most data warehouses have pruning or obsolete data operations that remove unwanted data. Using partitioning allows you to much more quickly and efficiently remove obsolete data: mysql> delete from t2 where -> c3 > date '1995-01-01' and c3 < date '1995-12-31'; Query OK, 805114 rows affected (47.41 sec) VS. mysql> alter table t1 drop partition p1; Query OK, 0 rows affected (0.03 sec) Records: 0 Duplicates: 0 Warnings: 0 The DROP PARTITION is A DDL operation, which runs much faster than a DML DELETE.

  32. Index Creation and Placement • If query patterns are known and predictable, and data is relatively static, then indexing isn’t that difficult • If the situation is a very ad-hoc environment, indexing becomes more difficult. Must analyze SQL traffic and index the best you can • Over-indexing a table that is frequently loaded / refreshed / updated can severely impact load and DML performance. Test dropping and re-creating indexes vs. doing in-place loads and DML. Realize, though, any queries will be impacted from dropped indexes • Index maintenance (rebuilds, etc.) can cause issues in MySQL (locking, etc.) • Remember some storage engines don’t support normal indexes (Archive, CSV) • Remember that a benefit of (most) column databases is that they do not need or use indexes

  33. Optimizing for data loads • The two biggest killers of load performance are (1) very wide tables for row-based tables; (2) many indexes on a table; • Stating the obvious, LOAD DATA INFILE and the high-speed loaders of column-based engines are the fastest way to load data vs. singleton or array insert statements • Column-based tables typically load faster than row-based tables with load utilities, however they will experience slower insert/delete rates than row-based tables • Loading data in primary key format helps some engines (e.g. InnoDB).

  34. Optimizing for data loads • Move the data as close to the database as possible; avoid having applications on remote machines do data manipulations and send data across the wire a row at a time – perhaps the worst way to load data • Oftentimes good to create staging tables then use procedural language to do data modifications and/or create flat files for high speed loaders • Loading data via time-based order helps some column databases like InfiniDB; logical range partitioning is then possible

  35. Monitoring and tuning the design

  36. Three performance analysis methods Bottleneck analysis Workload analysis Ratio analysis

  37. Bottleneck analysis • The focus of this methodology is the answer to the question “what am I waiting on?” • With MySQL, unfortunately, it can be difficult to determine latency in the database server • Lock contention rarely an issue in data warehouses • New MySQL performance schema has a ways to go in my opinion to be truly useful for bottleneck analysis • Problems found in bottleneck analysis translate into better lock handling in the app, partitioning improvements, better indexing, or storage engine replacement

  38. Workload analysis • The focus of this methodology is the answer to three questions: (1) Who’s logged on?; (2) What are they doing?; (3) How is my machine handing it? • Monitor active and inactive sessions. Keep in mind idle connections do take up resources • I/O and ‘hot objects’ a key area of analysis • Key focus should be on SQL statement monitoring and collection; something that goes beyond standard pre-production EXPLAIN analysis

  39. Horror story number two…

  40. The pain of slow SQL * Philip Russom, “Next Generation Data Warehouse Platforms”, TDWI, 2009.

  41. Workload analysis • SQL analysis basically becomes bottleneck analysis, because you’re asking where your SQL statement is spending its time • Once you have collected and identified your ‘top SQL’, the next step is to do tracing and interrogation into each SQL statement to understand its execution • Historical analysis is important too; a query that ran fine with 5 million rows may tank with 50 million or with more concurrent users • Design changes usually involve data file striping, indexing, partitioning, or parallel processing additions

  42. Ratio analysis • Least useful of all the performance analysis methods • May be OK to get a general rule of thumb as to how various resources are being used • Do not be misled by ratios; for example, a high cache hit ratio is sometimes meaningless. Databases can be brought to their knees by excessive logical I/O • Design changes from ratios typically include the altering of configuration parameters and sometimes indexing

  43. Conclusions • Design is the #1 contributor to the overall performance and availability of a system • With MySQL, you have greater flexibility and opportunity than ever before to build well-designed data warehouses • With MySQL, you now have more options and features available than ever before • The above translates into you being able to design data warehouses that can be future proofed: they can run as fast as you’d like (hopefully) and store as much data as you need (ditto)

  44. For More Information • Download InfiniDB Community Edition • Download InfiniDB documentation • Read InfiniDB technical white papers • Read InfiniDB intro articles on MySQL dev zone • Visit InfiniDB online forums • Trial the InfiniDB Enterprise Edition: http://www.calpont.com www.infinidb.org www.calpont.com

  45. The Thinking Person’s Guide to Data Warehouse Design Robin Schumacher rschumacher@calpont.com

More Related