Creating and Managing Indexes Using Proc SQL Chapter 6 1.

Slides:



Advertisements
Similar presentations
Effecting Efficiency Effortlessly Daniel Carden, Quanticate.
Advertisements

9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Managing Processing Using PROC SQL Chapter 8 1 Imelda Go, John Grego, Jennifer Lasecki, 2011.
Creating and Managing Views Using PROC SQL Chapter 7 1.
Chapter 11 Group Functions
Performing Queries Using PROC SQL Chapter 1 1 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
Introduction to Oracle9i: SQL1 Views. Introduction to Oracle9i: SQL2 Chapter Objectives Create a view, using CREATE VIEW command or the CREATE OR REPLACE.
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
Chapter 18: Modifying SAS Data Sets and Tracking Changes 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Chapter 2 Basic SQL SELECT Statements
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 4 – Creating New.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Chapter 10 Queries and Updating Part C. SQL Copyright 2005 Radian Publishing Co.
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Other database objects (Sequence). What Is a Sequence? A sequence: Automatically generates sequential numbers Is a sharable object Is typically used to.
Chapter 5 Sequences.
Database control Introduction. The Database control is a tool that used by the database administrator to control the database. To enter to Database control.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Introduction to Using the Data Step Hash Object with Large Data Sets Richard Allen Peak Stat.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Database Programming Sections 11 & 12 –Sequences, Indexes, and Synonymns.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Indexes and Views Unit 7.
Chapter 9: Advanced SQL and PL/SQL Guide to Oracle 10g.
PowerBuilder Online Courses - by Prasad Bodepudi Database Painter Primary & Foreign Keys Extended Attributes PowerBuilder System Tables Database Profiles.
Chapter 13 Views Oracle 10g: SQL. Oracle 10g: SQL2 Objectives Create a view, using CREATE VIEW command or the CREATE OR REPLACE VIEW command Employ the.
Chapter 19: Introduction to Efficient SAS Programming 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
A table is a set of data elements (values) that is organized using a model of vertical columns (which are identified by their name) and horizontal rows.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
Database Programming Sections 12 – Sequences, Indexes, and Synonymns.
Chapter 21: Controlling Data Storage Space 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without.
SAS Programming Training Instructor:Greg Grandits TA: Textbooks:The Little SAS Book, 5th Edition Applied Statistics and the SAS Programming Language, 5.
Writing Basic SQL SELECT Statements Lecture
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
 CONACT UC:  Magnific training   
SQL Basics Review Reviewing what we’ve learned so far…….
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
IFS180 Intro. to Data Management Chapter 10 - Unions.
Indexes By Adrienne Watt.
SQL Creating and Managing Tables
Database Performance Tuning and Query Optimization
PROC SQL, Overview.
Using the Set Operators
SQL Creating and Managing Tables
SQL Creating and Managing Tables
Chapter 5 Sequences.
Integrity Constraints
Chapter 2 Views.
Program Testing and Performance
Chapter 2 Views.
Relational Database Design
Chapter 11 Database Performance Tuning and Query Optimization
Subqueries.
A – Pre Join Indexes.
Presentation transcript:

Creating and Managing Indexes Using Proc SQL Chapter 6 1

What is An Index?  An index is an auxiliary file that stores the physical location of values for one or more specified columns in a table.  An index stores unique values for a specified column(s) in ascending order.  An index includes value/identifier pairs that allow you to access a row directly, by value.  You cannot create an index on a view. 2

Why Use An Index?  When a query is submitted on a table, PROC SQL accesses rows in a table in the order in which they are stored in the table, beginning with the first row and reading all rows in the table.  For large tables, it can be time consuming for PROC SQL to read all the rows in a table. 3

Why Use An Index?  An index on a table may allow a PROC SQL query to execute more efficiently.  We can refer to the LOG to view real time and CPU time (we will learn about STIMER in Chapter 8) for a partial measure of efficiency gains 4

Simple and Composite Indexes  Two types of indexes can be created –Simple – based on one column. The name of the index must be the name of the indexed column. –Composite – based on two or more columns. The name of the composite index cannot be the name of any existing column or index in the table. 5

Example - Creating A Simple Index  Suppose we had a table (meddb) containing all doctors claims for 100,000 patients. If we wanted to create an index on the patient’s Social Security Number (ssn), we would use the following code. proc sql; create index ssn create index ssn on meddb(ssn); on meddb(ssn); quit; quit; 6

Example - Creating A Composite Index  If we wanted to create a composite index on the patient’s Social Security Number (ssn) and the type of service the patient received (tos), we would use the following code proc sql; proc sql; create index ssntos create index ssntos on meddb(ssn,tos); on meddb(ssn,tos); quit; quit; 7

Unique Indexes  Simple and composite indexes can be defined as unique indexes.  Add the word unique before the word index when creating a unique index  If a table contains multiple occurrences of the same value in a column, a unique index cannot be defined on that column. 8

Costs of Using an Index  Additional CPU time  Additional input/output requests may be required  Additional memory  Additional disk space to store the index file 9

Guidelines for Creating Indexes  Keep the number of indexes to a minimum  Do not create an index for small tables  Do not create an index on a column that has a small number of distinct values (low cardinality)  Use indexes for queries that return a small subset of rows (< 15%) 10

Describe Table Statement  Use to display a CREATE INDEX statement in the SAS log for each index that is defined  If no indexes are defined for the specified table, a CREATE INDEX statement will not appear in the SAS log 11

MSGLEVEL = Option  To determine if an index is used, specify the SAS system option MSGLEVEL=I.  The default for the MSGLEVEL= option is MSGLEVEL=N. This will display notes, warnings, and error messages only. OPTIONS MSGLEVEL=I; 12

IDXWHERE = Option  IDXWHERE=YES –Tells SAS to choose the best index to process the WHERE expression  IDXWHERE=NO –Tells SAS to ignore all indexes  IDXNAME= index name –Tells SAS to use the specified index 13

Dropping Indexes Use the drop index statement to drop(delete) one or more indexes Use the drop index statement to drop(delete) one or more indexes proc sql; drop index ssn drop index ssn from claims; from claims; quit; quit; 14