SAP Sybase IQ 16.0: Performance and Tuning Guide
SAP Sybase IQ 16.0: Performance and Tuning Guide
SAP Sybase IQ 16.0: Performance and Tuning Guide
iv SAP Sybase IQ
Contents
vi SAP Sybase IQ
Audience
Audience
This document is intended for database administrators, database designers, and developers
who want to configure SAP® Sybase® IQ for improved performance.
2 SAP Sybase IQ
Performance Considerations
Performance Considerations
Performance is usually measured in response time and throughput. A good design and
indexing strategy leads to the largest performance gains.
Response time is the time it takes for a single task to complete. Several factors affect response
time:
• Reducing contention and wait times, particularly disk I/O wait times
• Using faster components
• Reducing the amount of time the resources are needed (increasing concurrency)
Throughput refers to the volume of work completed in a fixed time period. Throughput is
commonly measured in transactions per second (tps), but can be measured per minute, per
hour, per day, and so on.
To realize the largest performance gains run SAP Sybase IQ on a correctly configured system,
establish a good design,and choose the correct indexing strategy.
Other considerations, such as hardware and network analysis, can locate bottlenecks in your
installation.
4 SAP Sybase IQ
Hardware Configuration
Hardware Configuration
Hardware issues that impact SAP Sybase IQ performance.
Additional Information
Administration: Database > Run Database Servers > Command Line Switches > Command
Line Options for Performance > Memory Options > Number of CPUs Switch.
This condition may well be temporary. When some other query finishes, threads are made
available and the query may succeed the next time. If the condition persists, you may need to
restart the server and specify more SAP Sybase IQ threads. It is also possible that -iqmt is set
too low for the number of connections.
Network Performance
Minor changes in your environment can solve some network performance issues.
To improve network throughput, provide multiple network adaptors. Classes of users can be
assigned to different networks depending on service level agreements.
In case A (see the figure below) clients accessing two different database servers use one
network card. That means that clients accessing Servers A and B have to compete over the
network and past the network card. In the case B, clients accessing Server A use a different
network card than clients accessing Server B.
It would be even better to put your database servers on different machines. You may also want
to put heavy users of different databases on different machines.
6 SAP Sybase IQ
Hardware Configuration
8 SAP Sybase IQ
Server Configuration
Server Configuration
Understanding Memory
Understanding how SAP Sybase IQ allocates memory can help you get the best performance
from your system.
Server Memory
SAP Sybase IQ allocates heap memory for buffers, transactions, databases, and servers.
Shared memory may also be used, but in much smaller quantities.
At the operating system level, SAP Sybase IQ server memory consists of heap memory. For
the most part, you do not need to be concerned with whether memory used by SAP Sybase IQ
is heap memory or shared memory. All memory allocation is handled automatically. Make
sure that your operating system kernel is correctly configured to use shared memory before
you run SAP Sybase IQ
Most operating systems use a large percent of available memory for file system buffering.
Understand the buffering policies for your operating system to avoid over-allocating memory.
The total memory used for SAP Sybase IQ main and temporary buffer caches, plus SAP
Sybase IQ memory overhead, and memory used for the operating system and other
applications, must not exceed the physical memory on your system.
See also
• Required Memory on page 9
• Cache Memory on page 11
• Large Memory on page 11
• IQ Page Size on page 12
• Wired Memory on page 13
Required Memory
After you determine how much physical memory the operating system and other applications
require, calculate how much of the remaining memory is required by SAP Sybase IQ.
If you have a large number of users, the memory needed for processing threads increases. The
-gn switch controls the number of tasks (both user and system requests) that the database
server can execute concurrently. The -gss switch controls—in part—the stack size for server
execution threads that execute these tasks. SAP Sybase IQ calculates the stack size of these
worker threads using the following formula: (-gss + -iqtss).
The total number of threads (-iqmt plus -gn) must not exceed the number allowed for your
platform.
See also
• Server Memory on page 9
• Cache Memory on page 11
10 SAP Sybase IQ
Server Configuration
Cache Memory
Allocate as much memory as possible to the IQ main and temporary buffer caches for optimal
performance. Change the defaults to accommodate loads, queries, and applications.
Default cache size for the main and temporary buffer caches is 64MB each. Cache size is
controlled with the –iqmc (main cache) and –iqtc (temporary cache) server startup options.
These startup options only remain in effect while the server is running, so you need to include
them every time you restart the server.
Large memory requirements are one third of the total available physical memory allocated to
SAP Sybase IQ. To ensure adequate memory for the main and temporary IQ stores, set the –
iqlm, –iqmc, and –iqtc startup parameters so that each parameter receives one third of all
available physical memory.
See also
• Server Memory on page 9
• Required Memory on page 9
• Large Memory on page 11
• IQ Page Size on page 12
• Wired Memory on page 13
Large Memory
The –iqlm startup parameter specifies the maximum amount of large memory that SAP
Sybase IQ can dynamically request from the operating system.
Some load operations may require more large memory than the 2GB default provides. If
memory requirements exceed the default, use the - iqlm startup option to increase the memory
that SAP Sybase IQ can dynamically request from the OS. Set –iqlm as a switch as part of the
command or configuration file that starts the server.
(approximately 80% of the 128GB total) to SAP Sybase IQ processes. Following the general
rule, you would set the –iqlm, –iqtc, and –iqmc parameters to 33GB each.
See also
• Server Memory on page 9
• Required Memory on page 9
• Cache Memory on page 11
• IQ Page Size on page 12
• Wired Memory on page 13
IQ Page Size
IQ page and buffer cache size affect memory use and disk I/O throughput for the database.
SAP Sybase IQ performs I/O in units of page size. When you create a database, you specify a
separate page size for the catalog store and the IQ store. The temporary store has the same page
size as the IQ store.
Page size for the catalog store has no real impact on performance. The default value of 4096
bytes should be adequate. The IQ page size determines two other performance factors, the
default I/O transfer block size, and the maximum data compression for your database. SAP
Sybase IQ compresses all data. The amount of compression is determined by the IQ page
size.
Saving Memory
If your machine does not have enough memory, increase the memory and decrease the buffer
cache sizes. Decreasing the buffer caches too much, however, can make your data loads or
queries inefficient or incomplete due to insufficient buffers.
Note: The page size cannot be changed and determines the upper size limit on some database
objects and whether LOB features can be used.
See also
• Server Memory on page 9
• Required Memory on page 9
• Cache Memory on page 11
• Large Memory on page 11
• Wired Memory on page 13
12 SAP Sybase IQ
Server Configuration
Wired Memory
On HP and Solaris platforms, you can designate a specified amount of memory as wired
memory. Wired memory is shared memory that is locked into physical memory. The kernel
cannot page this memory out of physical memory.
Note: Use -iqwmem only if you have enough memory to dedicate the amount you specify for
this purpose. Otherwise, you can cause serious performance degradation.
• On Solaris, -iqwmem always provides wired memory.
• On HP, -iqwmem provides wired memory if you start the server as root. It provides
unwired memory if you are not root when you start the server. This behavior may change in
a future version.
See also
• Server Memory on page 9
• Required Memory on page 9
• Cache Memory on page 11
• Large Memory on page 11
• IQ Page Size on page 12
Tuning Options
Tuning options that provide faster query execution.
See also
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Limiting the Number of Statements on page 20
• Prefetching Cache Pages on page 20
• Controlling the Number of Prefetched Rows on page 21
• Controlling File System Buffering on page 22
• Optimizing the Cache Partitions on page 23
14 SAP Sybase IQ
Server Configuration
The optimal value for -iqgovern depends on the nature of your quer-
ies, number of CPUs, and size of the buffer cache. The default value
is 2*numCPU + 10. With a large number of connected users, you may
find that setting this option to 2*numCPU + 4 provides better
throughput.
-gn Sets the number of execution threads for the catalog store and con-
nectivity while running with multiple users. Usage:
-gn number of tasks (both user
and system requests) that the database server
can execute concurrently
The correct value for -gn depends on the value of -gm. The start_iq
utility calculates -gn and sets it appropriately. Setting -gn too low can
prevent the server from operating correctly. Setting -gn above 480 is
not recommended.
-c Sets the catalog store cache size. Usage:
-c catalog_store_cache_size
The catalog cache size is highly dependent on schema size and the
number of objects. The catalog store buffer cache is also the general
memory pool for the catalog store. To specify in MB, use the form -c
nM, for example, -c 64M.
For up to 1000 users, set -c to 16MB or higher. For up to 200 users, set
-c to 48MB (default).
Parameter Description
-cl and -ch Set upper (-ch) and lower (-cl) limits for the catalog store cache size.
-cl minimum cache size -ch maximum cache size. If the standard
catalog cache size is too small, set -cl and -ch parameters.
Do not use -c in the same configuration file or command line with -ch
or -cl. For related information, see the -ch cache-size option.
-iqmt Sets the number of processing threads. If -iqmt is set too low for the
-gm setting, then thread starvation can occur.
Note: To control catalog store cache size explicitly, you must do either of the following, but
not both, in your configuration file (.cfg) or on the command line for server startup:
• Set the -c parameter
• Set specific upper and lower limits for the catalog store cache size using the -ch and -cl
parameters
See also
• Optimizing for Typical Usage on page 14
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Limiting the Number of Statements on page 20
• Prefetching Cache Pages on page 20
• Controlling the Number of Prefetched Rows on page 21
• Controlling File System Buffering on page 22
• Optimizing the Cache Partitions on page 23
16 SAP Sybase IQ
Server Configuration
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Limiting the Number of Statements on page 20
• Prefetching Cache Pages on page 20
• Controlling the Number of Prefetched Rows on page 21
• Controlling File System Buffering on page 22
• Optimizing the Cache Partitions on page 23
If this option is set to 0 (the default), there is no limit, and no queries are rejected based on their
temporary space requirements.
To limit the actual temporary store usage per connection, set the
MAX_TEMP_SPACE_PER_CONNECTION option for all DML statements, including
queries. MAX_TEMP_SPACE_PER_CONNECTION monitors and limits the actual run time
temporary store usage by the statement. If the connection exceeds the quota set by the
MAX_TEMP_SPACE_PER_CONNECTION option, an error is returned and the current
statement rolls back.
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Limiting the Number of Statements on page 20
Set this option only to reject queries that consume vast resources.
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Limiting the Number of Statements on page 20
• Prefetching Cache Pages on page 20
• Controlling the Number of Prefetched Rows on page 21
• Controlling File System Buffering on page 22
• Optimizing the Cache Partitions on page 23
18 SAP Sybase IQ
Server Configuration
the temporary store node may degrade query performance. To improve performance,
eliminate the temporary store node by issuing the following command:
SET TEMPORARY OPTION FORCE_NO_SCROLL_CURSORS = ‘ON’
Note: If your application performs frequent backward-scrolling, setting the
FORCE_NO_SCROLL_CURSORS option to ON may actually degrade query performance, as
the absence of the temporary cache forces SAP Sybase IQ to re-execute the query for each
backward scroll.
If your application rarely performs backward-scrolling, make
FORCE_NO_SCROLL_CURSORS = ‘ON’ a permanent PUBLIC option. It will use less
memory and improve query performance.
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Limiting the Number of Statements on page 20
• Prefetching Cache Pages on page 20
• Controlling the Number of Prefetched Rows on page 21
• Controlling File System Buffering on page 22
• Optimizing the Cache Partitions on page 23
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Prefetching Cache Pages on page 20
• Controlling the Number of Prefetched Rows on page 21
• Controlling File System Buffering on page 22
• Optimizing the Cache Partitions on page 23
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
20 SAP Sybase IQ
Server Configuration
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
• Forcing Cursors to be Non-Scrolling on page 18
• Limiting the Number of Cursors on page 19
• Limiting the Number of Statements on page 20
• Prefetching Cache Pages on page 20
• Controlling File System Buffering on page 22
• Optimizing the Cache Partitions on page 23
To disable file system buffering for IQ Temporary dbspaces of existing databases, issue the
following statement:
SET OPTION "PUBLIC".OS_FILE_CACHE_BUFFERING_TEMPDB = OFF
You can only set this option for the PUBLIC role. Shut down the database and restart it for the
change to take effect.
This direct I/O performance option is available on Solaris UFS, Linux, Linux IBM, AIX, and
Windows file systems only. This option has no effect on HP-UX and HP-UXi and does not
affect databases on raw disk. In Linux, direct I/O is supported in kernel versions 2.6.x
To enable direct I/O on Linux kernel version 2.6 and AIX, also set the environment variable
IQ_USE_DIRECTIO to 1. Direct I/O is disabled by default in Linux kernel version 2.6 and
AIX. IQ_USE_DIRECTIO has no effect on Solaris and Windows.
Note:
• SAP Sybase IQ does not support direct I/O on Linux kernel version 2.4. If you set the
IQ_USE_DIRECTIO environment variable on Linux kernel version 2.4, the SAP Sybase
IQ server does not start. The error “Error: Invalid Block I/O argument,
maybe <pathname> is a directory, or it exceeds maximum file
size limit for the platform, or trying to use Direct IO on
unsupported OS” is reported.
• Solaris does not have a kernel parameter to constrain the size of its file system buffer cache.
Over time, the file system buffer cache grows and displaces the buffer cache pages, leading
to excess operating system paging activity and reduced performance. Use raw devices for
databases on Solaris whenever possible.
• Windows can bias the paging algorithms to favor applications at the expense of the file
system. This bias is recommended for SAP Sybase IQ performance.
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
22 SAP Sybase IQ
Server Configuration
Additional Information
• Reference: Statements and Options > Database Options > Alphabetical List of Options >
CACHE_PARTITIONS Option
• Reference: Statements and Options > Database Options > Alphabetical List of Options >
SWEEPER_THREADS_PERCENT Option
• Reference: Statements and Options > Database Options > Alphabetical List of Options >
WASH_AREA_BUFFERS_PERCENT Option
See also
• Optimizing for Typical Usage on page 14
• Optimizing for Large Numbers of Users on page 15
• Restricting Concurrent Queries on page 16
• Limiting Query Temp Space on page 17
• Limiting Queries by Rows Returned on page 18
Balancing Input/Output
Use disk striping, random and sequential file disk access to balance Input/Output (I/O).
Raw Devices
On UNIX-like operating systems, you can create a database or dbspace on a raw device or a
file system file.
Disk partitions are typically accessed in two modes: file system mode (for example through
the UFS file system) or raw mode. Raw mode does unbuffered I/O, generally making a data
transfer to or from the device with every read or write system call. UFS is the default UNIX file
system, and is a buffered I/O system which collects data in a buffer until it can transfer an
entire buffer at a time.
You create a database or dbspace on a raw device or a file system file. SAP Sybase IQ
determines automatically from the path name you specify whether it is a raw partition or a file
system file. Raw partitions can be any size.
See also
• Disk Striping on page 24
• Internal Striping on page 25
• Random and Sequential File Access on page 26
• Transaction and Message Logs on page 27
Disk Striping
Striping data across multiple disks is an essential technique for good performance.
Disk striping can be performed at different places in a system, often as part of RAID hardware
or software, for example:
• At the device layer, such as on a disk array or controller.
• In the operating system or dedicated device management software, such as Veritas.
• In the application.
By default, SAP Sybase IQ internally stripes pages across all files within a dbspace , so
additional striping at the software or hardware level are not needed for performance. Of
24 SAP Sybase IQ
Server Configuration
course, additional striping may be necessary as part of implementing storage redundancy for
the database, for example if RAID-5 is used.
Best performance in SAP Sybase IQ with storage redundancy is achieved with simple
mirroring or “RAID-1”. As stated above, SAP Sybase IQ will distribute the data across all of
the 2-disk mirror sets within a dbspace.
Due to cost, most SAP Sybase IQ databases will not use mirroring, and will be implemented
with RAID-5 or a similar RAID level to achieve redundancy. With RAID-5, choosing an
appropriate chunk size (how much data is written to one disk before moving on to the next
disk) will have a significant performance impact on the system, since RAID-5 has a significant
write overhead. If your application does frequent or time-sensitive loads, updates, or deletes,
or if queries often do temp dbspace I/O, a smaller chunk size in the range of 25-50% of the size
of a SAP Sybase IQ database page will likely give best performance. If your application is
mostly reads, with little write activity, a larger chunk size 75-100% of an SAP Sybase IQ page
size will likely provide best performance
Since SAP Sybase IQ normally attempts to prefetch multiple reads or flush multiple writes in
parallel, even with only a single active query, using a very small chunk size to spread each page
read or write across many disks will have little benefit, and will usually hurt performance.
When using RAID, best performance is usually achieved using hardware (such as controller or
array) based RAID. Software based RAID tools will work well, but may add a modest
additional performance load on the server’s CPUs.
See also
• Raw Devices on page 24
• Internal Striping on page 25
• Random and Sequential File Access on page 26
• Transaction and Message Logs on page 27
Internal Striping
Disk striping takes advantage of multiple disk spindles and provides the speed of parallel disk
writes.
SAP Sybase IQ provides disk striping, options without using third-party software. If you
already have a disk striping solution through third-party software and hardware, use that
method instead. Disk striping can be enabled by specifying the STRIPING ON option to the
CREATE DBSPACE command.
To change the default striping when creating a dbspace:
SET OPTION "PUBLIC".DEFAULT_DISK_STRIPING = { ON | OFF }
The default for the DEFAULT_DISK_STRIPING option is ON for all platforms. When disk
striping is ON, incoming data is spread across all dbspaces with space available. When disk
striping is OFF, dbspaces (disk segments) are filled up from the front on the logical file, filling
one disk segment at a time.
See also
• Raw Devices on page 24
• Disk Striping on page 24
• Random and Sequential File Access on page 26
• Transaction and Message Logs on page 27
See also
• Raw Devices on page 24
• Disk Striping on page 24
• Internal Striping on page 25
• Transaction and Message Logs on page 27
26 SAP Sybase IQ
Server Configuration
Message Log
SAP Sybase IQ logs all messages in the message log file, including error, status, and insert
notification messages. Limit the size of this file to conserve disk space.
At some sites the message log file tends to grow rapidly. To limit the size of this file:
• Set a maximum file size and archive the log files when the active message log is full
• Increase NOTIFY_MODULUS database option setting
• Use the NOTIFY parameter to turn off notification messages in LOAD TABLE. INSERT,
and CREATE INDEX statements
• Use -iqmsgsz switch to limit the size of the message log
Additional Information
• Utility Guide > start_iq Database Server Startup Utility > start_iq Server Options > -
iqmsgsz iqsrv16 Server Option
• Utility Guide > start_iq Database Server Startup Utility > start_iq Server Options > -m
iqsrv16 Server Option
• Reference: Statements and Options > Database Options > Alphabetical List of Options >
NOTIFY_MODULUS Option
• Reference: Statements and Options > SQL Statements > CREATE INDEX Statement
• Reference: Statements and Options > SQL Statements > INSERT Statement
• Reference: Statements and Options > SQL Statements > LOAD Statement
.
See also
• Raw Devices on page 24
• Disk Striping on page 24
• Internal Striping on page 25
• Random and Sequential File Access on page 26
Monitoring Performance
Tools you can use to determine whether your system is making optimal use of available
resources.
See Reference: Building Blocks, Tables, and Procedures > System Procedures >
System stored procedures > sp_iqconnection procedure
sp_iqcontext Tracks and displays, by connection, information about statements that are cur-
rently executing. Usage:
sp_iqcontext [ connhandle ]
See Building Blocks, Tables, and Procedures > System Procedures > System
stored procedures > sp_iqcontext procedure
28 SAP Sybase IQ
Server Configuration
Name Description
sp_iqcheckdb Checks validity of the current database. Optionally corrects allocation problems
for dbspaces or databases. Usage:
sp_iqcheckdb 'mode target [ … ] [ resources resource-
percent ]'
See Building Blocks, Tables, and Procedures > System Procedures > System
stored procedures > sp_iqcheckdb procedure
sp_iqdbstatistics Reports results of the most recent sp_iqcheckdb. Usage:
sp_iqdbstatistics
See Building Blocks, Tables, and Procedures > System Procedures > System
stored procedures > sp_iqdbstatistics procedure
sp_iqdbsize Displays the size of the current database. Usage:
sp_iqdbsize([ main ] )
See Building Blocks, Tables, and Procedures > System Procedures > System
stored procedures > sp_iqdbsize procedure
sp_iqspaceinfo Displays space usage by each object in the database. Usage:
sp_iqspaceinfo [‘main
| [table table-name | index index-name] [...] ‘]
See Building Blocks, Tables, and Procedures > System Procedures > System
stored procedures > sp_iqspaceinfo procedure
sp_iqstatus Displays miscellaneous status information about the database. Usage:
sp_iqstatus
See Building Blocks, Tables, and Procedures > System Procedures > System
stored procedures > sp_iqstatus procedure
sp_iqtablesize Displays the number of blocks used by each object in the current database and
the name of the dbspace in which the object is located. Usage:
sp_iqtablesize ( table_owner.table_name )
See Building Blocks, Tables, and Procedures > System Procedures > System
stored procedures > sp_iqtablesize procedure
See also
• Event Profiling Procedures on page 30
• Key Performance Indicators on page 30
• Buffer Cache Performance on page 32
sa_proce- Returns execution times for each line in database procedures, functions, events,
dure_profile or triggers. Usage:
sa_procedure_profile
[ filename
[, save_to_file ] ] )
sa_proce- Summarizes execution times for all procedures, functions, events, or triggers.
dure_profile_sum- Usage:
mary sa_procedure_profile_summary
[ filename
[, save_to_file ] ] )
Additional Information
• SQL Anywhere Server - SQL Reference > System procedures > Alphabetical list of
system procedures > sa_server_option system procedure.
• SQL Anywhere Server - SQL Reference > System procedures > Alphabetical list of
system procedures > sa_procedure_profile system procedure.
• SQL Anywhere Server - SQL Reference > System procedures > Alphabetical list of
system procedures > sa_procedure_profile_summary system procedure.
See also
• Database Profiling Procedures on page 28
• Key Performance Indicators on page 30
• Buffer Cache Performance on page 32
30 SAP Sybase IQ
Server Configuration
DBSpace and DBSpace File Statistics Dbspace and dbspace file size and available per-
centage.
Store Input and Output Statistics Store Input and Output Statistics identify store
reads and writes per second.
Operations and Request Statistics Average, minimum, maximum, and total waiting,
active, and total operations.
Multiplex Node Properties Role, status, and failover state of each multiplex
node.
Logical Server Engine Statistics CPU usage, connection, and connection statis-
tics.
Logical Server Cache Statistics Average, minimum, and maximum cache use sta-
tistics for the catalog, temporary, and main cache.
Logical Server Operations and Requests Statis- Average, minimum, maximum, and total waiting
tics and active operations.
Additional Information
For additional information, see the Sybase Control Center for SAP Sybase IQ online help in
SCC or at http://sybooks.sybase.com/sybooks/sybooks.xhtml?prodID=10680.
See also
• Database Profiling Procedures on page 28
• Event Profiling Procedures on page 30
• Buffer Cache Performance on page 32
32 SAP Sybase IQ
Server Configuration
LRU Waits 20% or less > 20%, which indicates a serious Check the operating
(LRUNum contention problem. system patch level and
TimeOuts other environment set-
percentage in tings. This problem
debug report) tends to be an O.S. is-
sue.
IOWait (ION- 10% or lower > 10% Check for disk errors
umWaits) or I/O retries
34 SAP Sybase IQ
Server Configuration
CPU time CPU Sys Seconds < 20% CPU Sys Seconds > 20% Adjust -iqgovern to re-
(CPU Sys duce allowed total
If CPU Total Seconds also re-
Seconds, number of concurrent
ports LOW utilization, and there
CPU Total queries.
are enough jobs that the system is
Seconds, in
busy, the cache may be thrashing Check Hit Rate and I/
debug report)
or parallelism may be lost. O Rates in the cache
report for cache
thrashing. Also check
if hash object is thrash-
ing by looking at the
hit rate of the has ob-
ject in cache_by_type
(or debug) report: is it
<90% while the I/O
rate (Writes) is high?
Check query plans for
attempted parallelism.
Were enough threads
available?
Does the system have a
very large number of
CPUs? Strategies such
as multiplex configu-
ration may be necessa-
ry.
Pin% (Pinned < 90% > 90 to 95%, indicating system is Try rebalancing the
buffers) dangerously close to an Out of cache sizes of main
Buffers condition, which would versus temp.
cause transactions to roll back
If rebalancing buffer
cache sizes is not pos-
sible, try reducing -iq-
govern to limit the
number of jobs run-
ning concurrently.
Free threads Free > Resrvd If the number of free threads Try one of the follow-
(ThrNum- drops to the reserved count, the ing:
Free) system may be thread starved.
Increase the number of
threads by setting -
iqmt.
Reduce thread-related
options:
MAX_IQ_THREAD
S_ PER_CON-
NECTION,
MAX_IQ_THREAD
S_ PER_TEAM.
Restrict query engine
resource allocations by
setting USER_RE-
SOURCE_ RES-
ERVATION.
Limit the number of
jobs by setting -iqgo-
vern.
36 SAP Sybase IQ
Server Configuration
Note: If one cache performs significantly more I/O than the other, reallocate some of the
memory in small amounts, such as 10 percent of the cache allocation on an iterative basis.
After reallocating, rerun the workload and monitor the performance changes.
Additional Information
Reference: Statements and Options > SQL Statements > IQ UTILITIES Statement
See also
• Database Profiling Procedures on page 28
• Event Profiling Procedures on page 30
• Key Performance Indicators on page 30
38 SAP Sybase IQ
Multiplex Performance
Multiplex Performance
Adjust your system for maximum performance or better use of disk space.
Each server in the multiplex can be on its own host or share a host with other servers. Two or
more servers on the same system consume no more CPU time than a single combined server
handling the same workload, but separate servers might need more physical memory than a
single combined server, because the memory used by each server is not shared by any other
server.
Addtional Information
Administration: Database > Appendix: Connection and Communication Parameters
Reference > Network Communications Parameters > VerifyServerName Communication
Parameter [Verify]
40 SAP Sybase IQ
Schema Design
Schema Design
Good database performance begins with good database design. Take the time to incorporate
design features into your schema during development for better response time and faster query
results.
Indexing
Indexing selection and solutions for SAP Sybase IQ.
See also
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
• Denormalizing for Performance on page 53
• UNION ALL Views for Faster Loads on page 54
• Hash Partitioning on page 56
Indexing Tips
Choose the correct column index type to make your queries run faster.
SAP Sybase IQ provides some indexes automatically—an index on all columns that optimizes
projections, and an HG index for UNIQUE and PRIMARY KEYS and FOREIGN KEYS.
While these indexes are useful for some purposes, you may need other indexes to process
certain queries as quickly as possible.
INDEX_ADVISOR
INDEX_ADVISOR generates messages when the optimizer would benefit from an additional
index on one or more columns in your query.
To activate the index advisor, set the INDEX_ADVISOR option ON. Messages print as part of a
query plan or as a separate message in the message log (.iqmsg) if query plans are not
enabled, and output is in OWNER.TABLE.COLUMN format.
LF or HG Indexes
Consider creating either an LF or HG index on grouping columns referenced by the WHERE
clause in a join query if the columns are not using enumerated FP storage. The optimizer may
need metadata from the enumerated FP or HG/LF index to produce an optimal query plan.
Non-aggregated columns referenced in the HAVING clause may also benefit from a LF or HG
index to help with query optimization. For example:
SELECT c.name, SUM(l.price * (1 - l.discount))
FROM customer c, orders o, lineitem l
WHERE c.custkey = o.custkey
AND o.orderkey = l.orderkey
AND o.orderdate >= "1994-01-01"
AND o.orderdate < "1995-01-01"
GROUP by c.name
HAVING c.name NOT LIKE "I%"
AND SUM(l.price * (1 - l.discount)) > 0.50
ORDER BY 2 desc
Adding indexes increases storage requirements and load time. Add indexes only if there is a
net benefit to query performance.
Additional Information
Reference: Statements and Options > Database Options > Alphabetical List of Options >
INDEX_ADVISOR Option
See also
• When and Where to use Indexes on page 42
• Simple Index Selection Criteria on page 43
• HG Index Loads on page 44
• Multi-Column Indexes on page 45
42 SAP Sybase IQ
Schema Design
See also
• Indexing Tips on page 41
• Simple Index Selection Criteria on page 43
• HG Index Loads on page 44
• Multi-Column Indexes on page 45
If the answer is yes, place an HG index on the column, or columns in the GROUP BY or
ORDER BY statement. Each column should also have a corresponding HG or LF index.
• Is this column part of a multicolumn primary key, constraint, or index?
If the answer is yes, place an HG or LF index on each column in the multicolumn index.
See also
• Indexing Tips on page 41
• When and Where to use Indexes on page 42
• HG Index Loads on page 44
• Multi-Column Indexes on page 45
HG Index Loads
Relative to other indexes, the HG indexes are more expense to maintain during data loads and
deletions. A main contributor to the performance of the HG index is the location of the data
within the HG index structure: the sparsity or density of the operation.
Dense HG operations are those in which the affected rows are tightly grouped around certain
keys. Sparse operations are those where there may be just a few rows per key that must be
affected. For instance, dates on data are typically grouped around the time the operation was
logged, data modified, etc. This means that new data will be placed at the end of the HG index
structure. When deleting data in the date HG index, said data would typically come off in
chunks of days, weeks, months, etc and thus be removed from the beginning of the HG btree or
be tightly grouped around a few keys for deletion. These operations are very fast, relatively
speaking, as SAP Sybase IQ will operate on a few pages and affect a tremendous number of
rows.
Data that is rather sparse, like Prices, Customer IDs, City, Country, etc., are very different. As
“pricing" data, for instance, is loaded each value will vary widely across all data already in the
index. If the column is tracking stock prices the numeric field to store that data will be densely
updated because the data being changed will be across the nearly the entire range of values
already loaded. These operations are slower due to the amount of index pages that must be
maintained for each row being affected. A worst case scenario is that SAP Sybase IQ is forced
to read and write 1 page for EACH ROW being loaded or deleted. While this can be less than
optimal, SAP Sybase IQ has been design to parallel process phase 2 of the HG index loads and
the deletes so that the impact is greatly reduced.
All of this is well and good, but how does it affect the data model design and indexing? Typical
tuning and optimization within SAP Sybase IQ generally boils down to indexes or the lack
thereof. Knowing how the indexes can be affected by the data and loading is an important
aspect when deciding which indexes to put in place and which to leave off. Because HG
indexes take, relatively, more time to load than other indexes they are often the subject of focus
when it comes to use and design. Certainly, HG indexes can help with query performance.
There are times, though, where adding an index may have a slight positive impact on queries
44 SAP Sybase IQ
Schema Design
but have more of an impact to data loads. In these situations, it is important to understand why
the load or delete took longer and what can be done about it.
The sparsity or density of new data with respect to currently loaded data plays a critical role in
this. If a relatively random column of a Customer ID must be indexed for fast query
performance and an index must be on that column. Suppose, though, that a primary key exists
on the table and it is the Customer ID and a Date field storing a transaction datetime. If the
ordering were left as (customer_id, transaction_date) the data would be sparsely
loaded or deleted from the table in most case. Data being loaded will be done so by transaction
date. Since the Customer ID column is first in the multicolumn index, though, it will force SAP
Sybase IQ to touch data throughout the entire HG index structure.
A simple change in order to (transaction_date, customer_id) changes this
behavior. The index is still in place to control referential integrity for the primary key. The
ordering of the columns is immaterial for primary key enforcement. As such, we can change
the column order without causing any downstream ill effects. This simple change will now
force all new data being loaded by transaction date to be inserted at the end of the HG index
structure in a very dense manner. Over time the loads will perform consistently as the data is,
generally, always going to the end of the HG structure.
Simply changing the column ordering in a multicolumn index can have drastic impacts on
performance. The size of the HG index shouldn't change much as the data is still the same width
regardless of order. What will change is how fast the data is loaded or deleted from the table.
See also
• Indexing Tips on page 41
• When and Where to use Indexes on page 42
• Simple Index Selection Criteria on page 43
• Multi-Column Indexes on page 45
Multi-Column Indexes
Currently, only HG, UNIQUE HG, UNIQUE CONSTRAINT, and PRIMARY KEY indexes
support multiple columns in index creation, but multi-column indexes are also useful for
GROUP BY and ORDER BY statements.
From a statistics point of view, multi-column indexes provide enough information in multi-
column table joins to let the optimizer know the exact statistics of the join and whether or not it
is a many-to-many or one-to-many join. The optimizer is also smart enough to use the
statistics for optimization, but use individual HG/LF indexes for the actual work. The
optimizer costs out all join and sort scenarios and decides which index(es) is best for that
operation. The statistics help it get to that point.
Some items to keep in mind about the HG indexes:
• HG inserts are the most expensive
• Try to guarantee that inserts will happen at the end of the index
Place generally incrementing data, like a transaction date or batch number (sequential data), at
the beginning of the index list. Something that will try to guarantee a sequential key.
See also
• Indexing Tips on page 41
• When and Where to use Indexes on page 42
• Simple Index Selection Criteria on page 43
• HG Index Loads on page 44
Join Column
For joins, keep the data types as narrow as possible to reduce disk I/O and memory
requirements.
Because integer comparisons are quicker than character comparisons, use integer data types
(unsigned if possible) in joins. Keeping the data types as narrow as possible improves join
performance by reducing disk I/O and memory requirements. Because the HG index has
slightly more capability from a join perspective, use an HG index on join columns rather than a
cardinality appropriate index (LF or HG) . This should be weighed against the potential
increase in time to load the HG index as compared to the LF index.
See also
• Indexing on page 41
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
• Denormalizing for Performance on page 53
• UNION ALL Views for Faster Loads on page 54
• Hash Partitioning on page 56
46 SAP Sybase IQ
Schema Design
Primary Keys
Multi-column primary keys should have an additional LF or HG index placed on each column
specified in the primary key. This must be done manually as SAP Sybase IQ only creates an HG
index on the composite columns.
UNIQUE constraint, UNIQUE HG, and primary key share an identical structure. That
structure uses an HG index with no G-Array to store the row ids. When possible, use primary
keys on tables. This helps the optimizer make more informed query path decisions even if the
index is not used. The index structure provides detailed statistics to help the optimizer make
better choices as well as providing a structure to traverse the data.
See also
• Indexing on page 41
• Join Column on page 46
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
• Denormalizing for Performance on page 53
• UNION ALL Views for Faster Loads on page 54
• Hash Partitioning on page 56
Foreign Keys
As with primary keys, use foreign keys to improve query join performance. This gives SAP
Sybase IQ one more piece of information on how tables are joined and the statistics behind
those joins. SAP Sybase IQ automatically creates an HG Index on the foreign key column, so
no additional HG or LF index is necessary. A foreign key requires that a primary key exists on
referenced table.
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
48 SAP Sybase IQ
Schema Design
Null Values
Defining columns as NULL or NOT NULL helps the optimizer work more efficiently.
Specifying NULL or NOT NULL allows the optimizer a more educated guess at joins and
search criteria by having one more piece of information about the characteristics of the data.
NULL data does not save space on the database page, as it would in other databases. NULL data
will, however, be compressed out when stored on disk due to the SAP Sybase IQ compression
algorithms and optimized indexes.
• Always specify NULL or NOT NULL
• Open Client and ODBC connections have different default behavior when table is created
• Give the optimizer an additional piece of information about the characteristics of the data
for joins and search arguments
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
• Denormalizing for Performance on page 53
• UNION ALL Views for Faster Loads on page 54
• Hash Partitioning on page 56
longer have to perform sign comparison. This increases performance and eliminates a step in
the joining and searching of data, particularly for key columns.
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
• Denormalizing for Performance on page 53
• UNION ALL Views for Faster Loads on page 54
• Hash Partitioning on page 56
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
50 SAP Sybase IQ
Schema Design
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Temporary Tables on page 52
• Denormalizing for Performance on page 53
Temporary Tables
If you want the data to persist through transaction commits, use the ON COMMIT PRESERVE
ROWS option when you create global temporary tables or declare local temporary tables.
There are three types of Temporary Tables:
• # tables
CREATE TABLE #temp_table( col1 int )
• Local Temporary Tables
DECLARE LOCAL TEMPORARY TABLE temp_table ( col1 int )
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Denormalizing for Performance on page 53
• UNION ALL Views for Faster Loads on page 54
• Hash Partitioning on page 56
52 SAP Sybase IQ
Schema Design
Deciding to Denormalize
Analyze the data access requirements of the applications in your environment and their actual
performance characteristics, including:
• What are the critical queries, and what is the expected response time?
• What tables or columns do they use? How many rows per access?
• What is the usual sort order?
• What are concurrency expectations?
• How big are the most frequently accessed tables?
• Do any processes compute summaries?
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
• UNION ALL Views for Faster Loads on page 54
• Hash Partitioning on page 56
Each month, you can load data into a single base table—JANUARY, FEBRUARY, or
MARCH in this example. Next month, load data into a new table with the same columns, and
the same index types.
Note: You cannot perform an INSERT...SELECT into a UNION ALL view. UNION ALL
operators are not fully parallel in this release. Their use may limit query parallelism.
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
54 SAP Sybase IQ
Schema Design
See also
• UNION ALL View Performance on page 55
To work around this performance issue, queries should have the DISTINCT operator
evaluated before the ORDER BY, where the sort order is ASC and the optimization can be
applied:
SELECT c.state FROM (SELECT DISTINCT state
FROM testVUA) c
ORDER BY c.state DESC;
See also
• Queries Referencing UNION ALL Views on page 55
Hash Partitioning
Hash table partitioning distributes data to logical partitions for parallel execution, which can
enhance join performance on large tables and distributed queries (PlexQ).
New join algorithms and aggregation algorithms can take advantage of hash partitioning by
reducing the amount of intermediate storage and network transfer required as well as
providing increased parallelism by leveraging the semantic division of the table rows into
partitions. The improved cache behavior provided by data affinity and affinity based work
allocation provide further scalability in the PlexQ environment.
Large Memory
Some load operations may require more large memory than the 2GB default provides. If the
memory requirements exceed the default, use the - iqlm startup option to increase the memory
that SAP Sybase IQ can dynamically request from the OS.
As a general rule, large memory requirements represent one third of the total available
physical memory allocated to SAP Sybase IQ. To ensure adequate memory for the main and
temporary IQ stores, set the –iqlm, –iqtc, and –iqmc startup parameters so that each parameter
receives one third of all available physical memory allocated to SAP Sybase IQ.
56 SAP Sybase IQ
Schema Design
In most cases, you should allocate 80% of total physical memory to SAP Sybase IQ to prevent
SAP Sybase IQ processes from being swapped out. Adjust actual memory allocation to
accommodate other processes running on the same system. For example, on a machine with
32 cores and 128GB of total available physical memory, you would allocate 100GB
(approximately 80% of the 128GB total) to SAP Sybase IQ processes. Following the general
rule, you would set the –iqlm, –iqtc, and –iqmc parameters to 33GB each.
Additional Information
• Reference: Statements and Options > Database Options > Alphabetical List of Options >
JOIN_PREFERENCE Option
• Reference: Statements and Options > Database Options > Alphabetical List of Options >
AGGREGATION_PREFERENCE Option
• Utility Guide > start_iq Database Server Startup Utility > start_iq Server Options > –iqlm
iqsrv16 Server Option
• Utility Guide > start_iq Database Server Startup Utility > start_iq Server Options > –iqmc
iqsrv16 Server Option
• Utility Guide > start_iq Database Server Startup Utility > start_iq Server Options > –iqtc
iqsrv16 Server Option
See also
• Indexing on page 41
• Join Column on page 46
• Primary Keys on page 47
• Foreign Keys on page 47
• Proper Data Type Sizing on page 48
• Null Values on page 49
• Unsigned Data Types on page 49
• LONG VARCHAR and LONG VARBINARY on page 50
• Large Object Storage on page 51
• Temporary Tables on page 52
• Denormalizing for Performance on page 53
• UNION ALL Views for Faster Loads on page 54
58 SAP Sybase IQ
Troubleshooting
Troubleshooting
Identify and solve common performance issues.
See also
• Diagnostic Tools on page 59
• Common Performance Issues on page 60
Diagnostic Tools
Utilities on your operating system that monitor system activities.
Use these utilities to get statistics on the number of running processes, including and the
number of page-outs and swaps. Use this information to find out if the system is paging
excessively, then make any necessary adjustments. You may want to put your swap files on
special fast disks.
OS Utility Description
UNIX top, topas Provides an ongoing look at processor activity in real
time.
top is available on Solaris, Linux, and HP-UX plat-
forms. topas is available on AIX.
OS Utility Description
ps Reports process status.
vmstat Displays information about system processes, mem-
ory, paging, block IQ, traps, and CPU activity.
iostat -x Displays disk subsystem information.
sar Writes selected OS activity results to standard out-
put.
Windows Task Manager, Resource Provide detailed information about computer per-
Monitor formance and running applications, processes, CPU
usage, and other system services.
Note: To access System Monitor, select the object Logical Disk, the instance of the disk
containing the file PAGEFILE.SYS, and the counter Disk Transfers/Sec.
Put the Windows page files on different disks than your database dbspace devices. You can
also monitor the Object Memory and the counter Pages/Sec. However, this value is the sum of
all memory faults which includes both soft and hard faults.
See also
• Isolating Performance Problems on page 59
• Common Performance Issues on page 60
See also
• Isolating Performance Problems on page 59
• Diagnostic Tools on page 59
60 SAP Sybase IQ
Troubleshooting
when the operating system must go out to disk and retrieve any data before a memory request
can be satisfied. Good memory management avoids or minimizes paging or swapping.
The most frequently used operating system files are swap files. When memory is exhausted,
the operating system swaps pages of memory to disk to make room for new data. When the
pages that were swapped are called again, other pages are swapped, and the required memory
pages are brought back. This is very time-consuming for users with high disk usage rates. Try
to organize memory to avoid swapping and, thus, to minimize use of operating system files.
To make the maximum use of your physical memory, SAP Sybase IQ uses buffer caches for all
reads and writes to your databases.
Note: Your swap space on disk must be at least large enough to accommodate all of your
physical memory. Having swap/paging space striped across fast disks is essential.
See also
• Index and Row Fragmentation on page 61
• Catalog File Growth on page 62
• Thrashing and Query Execution on page 62
Review the output and decide whether you want to recreate, reorganize, or rebuild the indexes.
You can create other indexes to supplement the FP index.
Additional Information
• Reference: Building Blocks, Tables, and Procedures > System Procedures >
sp_iqrowdensity procedure.
• Reference: Building Blocks, Tables, and Procedures > System Procedures >
sp_iqindexfragmentation procedure.
See also
• Paging and Disk Swapping on page 60
• Catalog File Growth on page 62
• Thrashing and Query Execution on page 62
See also
• Paging and Disk Swapping on page 60
• Index and Row Fragmentation on page 61
• Thrashing and Query Execution on page 62
or
Hash find thrashing detected
Take one or more of the following actions to provide the query with the resources required for
execution:
• Relax the paging restriction by increasing the value of HASH_THRASHING_PERCENT.
• Increase the size of the temporary cache. Keep in mind that increasing the size of the
temporary cache requires an equal size reduction in main cache allocation to prevent the
possibility of system thrashing.
62 SAP Sybase IQ
Troubleshooting
• Attempt to identify and alleviate why SAP Sybase IQ is not estimating one or more hash
sizes for this statement correctly. For example, check that all columns that need an LF or
HG index have one. Also consider if a multicolumn index is appropriate.
• Decrease the value of the database option HASH_PINNABLE_CACHE_PERCENT.
To identify possible problems with a query, generate a query plan by running the query with
the temporary database options QUERY_PLAN='ON' and QUERY_DETAIL ='ON'.
Examine the estimates in the query plan.
See also
• Paging and Disk Swapping on page 60
• Index and Row Fragmentation on page 61
• Catalog File Growth on page 62
64 SAP Sybase IQ
Queries and Deletions
Structuring Queries
Improving query structures can make your queries run faster.
• In some cases, command statements that include subqueries can also be formulated as
joins and may run faster.
• If you group on multiple columns in a GROUP BY clause, list the columns by descending
order by number of unique values if you can. This will give you the best query
performance.
• You can improve performance by using an additional column to store frequently
calculated results.
In the above example, the HG index vertically projects x and y in sorted order.
If the ROWID() function is in the SELECT list expressions, multicolumn HG indexes are also
used. For example:
SELECT rowid()+x, z FROM T
ORDER BY x,y,z
If ROWID() is present at the end of an ORDER BY list, and if the columns of that list—except
for ROWID()— exist within the index, and the ordering keys match the leading HG columns
in order, multicolumn indexes are used for the query. For example:
SELECT z,y FROM T
ORDER BY x,y,z,ROWID()
See also
• Improved Subquery Performance on page 66
• Using Caching Methods on page 66
See also
• Enhancing ORDER BY Query Performance on page 65
• Using Caching Methods on page 66
See also
• Enhancing ORDER BY Query Performance on page 65
• Improved Subquery Performance on page 66
66 SAP Sybase IQ
Queries and Deletions
Query plans generate an execution tree that consists of a series of nodes that represent a
processing stage. The lowest nodes on the tree are leaf nodes. Each leaf node represents a table
in the query. At the top of the plan is the root of the operator tree. Information flows up from the
tables and through any operators representing joins, sorts, filters, stores, aggregation, and
subqueries.
the query when producing its query plan. When QUERY_PLAN and
QUERY_PLAN_AS_HTML are OFF, this option is ignored.
• QUERY_PLAN – When set ON (the default), Sybase IQ produces messages about queries.
• QUERY_PLAN_TEXT_ACCESS – When this option is turned ON, you can view, save, and
print IQ query plans from the Interactive SQL client. When
QUERY_PLAN_ACCESS_FROM_CLIENT is turned OFF, query plans are not cached,
and other query plan-related database options have no affect on the query plan display
from the Interactive SQL client. This option is OFF by default.
See “GRAPHICAL_PLAN function [String]” and “HTML_PLAN function [String]” in
Reference: Building Blocks, Tables, and Procedures.
• QUERY_PLAN_AFTER_RUN – When set ON, the query plan is printed after the query has
finished running. This allows the plan to include additional information, such as the actual
number of rows passed on from each node of the query. In order for this option to work,
QUERY_PLAN must be ON. This option is OFF by default.
• QUERY_PLAN_AS_HTML – Produces a graphical query plan in HTML format for
viewing in a Web browser. Hyperlinks between nodes make the HTML format much easier
to use than the text format in the .iqmsg file. Use the QUERY_NAME option to include the
query name in the file name for the query plan. This option is OFF by default.
• QUERY_PLAN_AS_HTML_DIRECTORY – When QUERY_PLAN_AS_HTML is ON and
a directory is specified with QUERY_PLAN_AS_HTML_DIRECTORY, Sybase IQ writes
the HTML query plans in the specified directory.
• QUERY_PLAN_TEXT_CACHING – Gives users a mechanism to control resources for
caching plans. With this option OFF (the default), the query plan is not cached for that user
connection.
If the QUERY_PLAN_TEXT_ACCESS option is turned OFF for a user, the query plan is
not cached for the connections from that user, no matter how
QUERY_PLAN_TEXT_CACHING is set.
See also “GRAPHICAL_PLAN function [String]” and “HTML_PLAN function [String]”
in Reference: Building Blocks, Tables, and Procedures.
• QUERY_TIMING – Controls the collection of timing statistics on subqueries and some
other repetitive functions in the query engine. Normally it should be OFF (the default)
because for very short correlated subqueries the cost of timing every subquery execution
can be very expensive in terms of performance.
• QUERY_PLAN_MIN_TIME – Specifies a threshold for query execution. The query plan is
generated only if query execution time exceeds the threshold in microseconds. This can
improve system performance by turning off query plan generation for queries with very
short execution times.
Note: Query plans can add a lot of text to your .iqmsg file. When QUERY_PLAN is ON, and
especially if QUERY_DETAIL is ON, you might want to enable message log wrapping or
message log archiving to avoid filling up your message log file.
68 SAP Sybase IQ
Queries and Deletions
See also
• Using Query Plans on page 69
Additional Information
• Reference: Building Blocks, Tables, and Procedures > SQL Functions >
GRAPHICAL_PLAN function [String]
• Reference: Building Blocks, Tables, and Procedures > SQL Functions > HTML_PLAN
function [String]
• Reference: Statements and Options > Database Options >
QUERY_PLAN_TEXT_ACCESS Option
• Reference: Statements and Options > Database Options >
QUERY_PLAN_TEXT_CACHING Option
See also
• Query Evaluation Options on page 67
See also
• Setting Query Priority on page 70
• Setting Query Optimization Options on page 71
• Setting User-Supplied Condition Hints on page 71
• Monitoring Workloads on page 72
See also
• Setting Query Time Limits on page 70
• Setting Query Optimization Options on page 71
• Setting User-Supplied Condition Hints on page 71
• Monitoring Workloads on page 72
70 SAP Sybase IQ
Queries and Deletions
See also
• Setting Query Time Limits on page 70
• Setting Query Priority on page 70
• Setting User-Supplied Condition Hints on page 71
• Monitoring Workloads on page 72
important factor in these decisions is the selectivity of the condition; that is, the fraction of the
table’s rows that satisfy that condition.
The optimizer normally decides without user intervention, and it generally makes optimal
decisions. In some situations, however, the optimizer might not be able to accurately
determine the selectivity of a condition before it has been executed. These situations normally
occur only where either the condition is on a column with no appropriate index available, or
where the condition involves some arithmetic or function expression and is, therefore, too
complex for the optimizer to accurately estimate.
Additional Information
• Reference: Building Blocks, Tables, and Procedures > SQL Language Elements > User-
supplied Condition Hints
See also
• Setting Query Time Limits on page 70
• Setting Query Priority on page 70
• Setting Query Optimization Options on page 71
• Monitoring Workloads on page 72
Monitoring Workloads
Use the stored procedures that monitor table, column, and index usage for better query
performance.
Indexes are often created to provide optimization metadata and to enforce uniqueness and
primary/foreign key relationships. Once an index is created, however, DBAs face the
challenge of quantifying benefits that the index provides.
Tables are often created in the IQ Main Store for the temporary storage of data that must be
accessed by multiple connections or over a long period. These tables might be forgotten while
they continue to use valuable disk space. Moreover, the number of tables in a data warehouse is
too large and the workloads are too complex to manually analyze usage.
Thus, unused indexes and tables waste disk space, increase backup time, and degrade DML
performance.
SAP Sybase IQ offers tools for collecting and analyzing statistics for a defined workload.
DBAs can quickly determine which database objects are being referenced by queries and
should be kept. Unused tables/columns/indexes can be dropped to reduce wasted space,
improve DML performance, and decrease backup time.
Workload monitoring is implemented using stored procedures, which control the collection
and report detailed usage of table, column, and, index information. These procedures
complement INDEX_ADVISOR functionality, which generates messages suggesting
additional column indexes that may improve performance of one or more queries. Once
72 SAP Sybase IQ
Queries and Deletions
recommended indexes have been added, their usage can be tracked to determine if they are
worth keeping.
See also
• Setting Query Time Limits on page 70
• Setting Query Priority on page 70
• Setting Query Optimization Options on page 71
• Setting User-Supplied Condition Hints on page 71
HG Delete Operations
SAP Sybase IQ chooses one of three algorithms to process delete operations on columns with
an HG (High_Group) index.
• Small delete provides optimal performance when rows are deleted from very few groups.
It is typically selected when the delete is only 1 row or the delete has an equality predicate
on the columns with an HG index. The small delete algorithm can randomly access the HG.
Worst case I/O is proportional to the number of groups visited.
• Mid delete provides optimal performance when rows are deleted from several groups, but
the groups are sparse enough or few enough that not many HG pages are visited. The mid
delete algorithm provides ordered access to the HG. Worst case I/O is bounded by the
number of index pages. Mid delete has the added cost of sorting the records to delete.
• Large delete provides optimal performance when rows are deleted from a large number of
groups. The large delete scans the HG in order until all rows are deleted. Worst case I/O is
bounded by the number of index pages. Large delete is parallel, but parallelism is limited
by internal structure of the index and the distribution of group to deleted from. Range
predicates on HG columns can be used to reduce the scan range of the large delete.
HG Delete Costing
The delete cost model considers many factors including I/O costs, CPU costs, available
resources, index metadata, parallelism, and predicates available from the query.
Specifying predicates on columns that have HG, LF, or enumerated FP indexes greatly
improves costing. In order for the HG costing to pick an algorithm other than large delete, it
must be able to determine the number of distinct values (groups) affected by deletions.
Distinct count is initially assumed to be lesser of the number of index groups and the number
of rows deleted. Predicates can provide an improved or even exact estimate of the distinct
count.
Costing currently does not consider the effect of range predicates on the large delete. This can
cause mid delete to be chosen in cases where large delete would be faster. You can force the
large delete algorithm if needed in these cases, as described in the next section.
See also
• WD Delete Operations on page 74
• TEXT Delete Operations on page 75
WD Delete Operations
SAP Sybase IQ chooses one of three algorithms to process delete operations on columns with
a WD (Word) index.
• Small delete provides optimal performance when the rows deleted contain few distinct
words, so that not many WD pages need to be visited. The WD small delete algorithm
performs an ordered access to the WD. Worst case I/O is bounded by the number of index
pages. Small delete incorporates the cost of sorting the words and record IDs in the records
to delete.
• Mid delete for WD is a variation of WD small delete, and is useful under the same conditions
as small delete, that is, when the rows deleted contain few distinct words. Mid delete for WD
sorts only words in the records to delete. This sort is parallel, with parallelism limited by
the number of words and CPU threads available. For Word index, the mid delete method is
generally faster than small delete.
• Large delete provides optimal performance when the rows deleted contain a large number
of distinct words, and therefore need to visit a large number of “groups” in the index. The
large delete scans the WD in order, until all rows are deleted. Worst case I/O is bounded by
the number of index pages. Large delete is parallel, but parallelism is limited by the
internal structure of the index and the distribution of groups from which to delete.
74 SAP Sybase IQ
Queries and Deletions
WD Delete Costing
The WD delete cost model considers many factors including I/O costs, CPU costs, available
resources, index metadata, and parallelism.
You can use the WD_DELETE_METHOD database option to control WD delete performance.
See also
• HG Delete Operations on page 73
• TEXT Delete Operations on page 75
See also
• HG Delete Operations on page 73
• WD Delete Operations on page 74
76 SAP Sybase IQ
Index
Index
Columns
-gm 15 Null Values 65
-iqgovern Common performance issues 60
Restricting Queries To Improve Performance Condition Hints
16 Setting 71
-iqwmem 13 Connections
Connection Requests 15
A Limiting Statements 20
CPU
AGGREGATION_ALGORITHM_ availability 5
PREFERENCE 71 setting number 5
Cursors
Forcing Non-scrolling 18
B Limiting 19
Block Size
Relationship To IQ Page Size 12 D
BT_PREFETCH_MAX_MISS 20 Data Compression
Buffer Cache Page Size 12
Block Size 12 Data Model Recommendations 41
Data Compression 12 Data Type Sizing 48
Database Access, Multiuser 9 Data types
Memory Use 9 LONG VARBINARY 50
Memory, Saving 12 LONG VARCHAR 50
Overhead 9 Null Values 49
Page Size 12 Sizing 48
Thread Stacks 9 Data Types
Buffer Cache Performance 32 Unsigned Data Types 49
Cache Monitor 32 Database Access
Cache Monitor Checklist 32 Multiuser 9
Buffer Caches Databases
Layout 23 Procedure Profiling 28
Procedures 28
C DATABASES
DENORMALIZING FOR PERFORMANCE
Cache Memory 53
–iqmc 11 DATE indexes 42, 43
–iqtc 11 Dbspace
Cache Size 11 Limiting Use 17
Parameters 11 DEFAULT_HAVING_SELECTIVITY 71
Prefetching Pages 20 DEFAULT_LIKE_MATCH_SELECTIVITY 71
Cache Monitor Checklist 32 DEFAULT_LIKE_RANGE_SELECTIVITY 71
CACHE_PARTITIONS 23 Delete Operations
Caching Methods 66 Optimizing 73
Catalog File Growth 62 TEXT Delete Operations 75
CMP indexes 42, 43 WD Delete Operations 74
78 SAP Sybase IQ
Index
IQGOVERN_PRIORITY 70 multithreading 5
iqnumbercpus process threading model 5
setting number of CPUs 5 Memory 9
Cache Memory 11
Cache Size 11
J Connection Requests 15
Join Column 46 File System Buffering 22
JOIN_ALGORITHM_PREFERENCE 71 Heap Memory 9
JOIN_PREFERENCE 55 IOS_FILE_CACHE_BUFFERING 22
IQ_USE_DIRECTIO 22
Large Memory 11
K Limits 9
Key Performance Indicators Page Size 12
Logical Server Statistics 30 Required Memory 9
Multiplex and Node-Related Statisitics 30 Server Memory 9
Server Statisitics 30 Wired Memory 13
Keys Memory Use
Foreign Keys 47 Other 9
Primary Keys 47 Message Log
Limiting Size 27
Monitoring Performance
L Buffer Cache Performance 32
Large Memory Cache Monitor 32
–iqmc 11 Database Profiling Procedures 28
–iqtc 11 Event Profiling Procedures 30
Multiplex Servers 11 Key Performance Indicators 30
Simplex Servers 11 Monitoring Workloads 72
Large Object Storage 51 Multi-Column Indexes 45
LF indexes 42, 43 Multi-user Performance 20
lightweight processes 5 Multicolumn Indexes 65
load balancing multiplex 39
among query servers 40 Multiplex and Node-Related Statisitics 30
Load Plans 66 multiplex databases
Logical Server Statistics 30 disk space 39
logical servers 39 multiplex resources
LONG VARBINARY 50 dynamically adjusting 39
LONG VARCHAR 50 multithreading
performance impact 5
M
N
management, resources
buffer cache 3 networks
MAX_CURSOR_COUNT 19 large data transfers 6
MAX_HASH_ROWS 71 networks 6
MAX_QUERY_TIME 70 performance 6
MAX_STATEMENT_COUNT 20 performance suggestions 6
memory settings 6
balancing I/O 24 Null Values 49
lightweight processes 5
O MAX_HASH_ROWS 71
Options, Query Plans
Optimizing
INDEX_ADVISOR 67
Queries 65
NOEXEC 67
Optimizing Queries 41, 65
QUERY_DETAIL 67
Options
QUERY_PLAN 67
AGGREGATION_ALGORITHM_
QUERY_PLAN_AFTER_RUN 67
PREFERENCE 71
QUERY_PLAN_AS_HTML 67
BT_PREFETCH_MAX_MISS 20
QUERY_PLAN_AS_HTML_DIRECTORY
CACHE_PARTITIONS 23
67
DEFAULT_HAVING_SELECTIVITY 71
QUERY_PLAN_TEXT_ACCESS 67
DEFAULT_LIKE_MATCH_SELECTIVITY
QUERY_PLAN_TEXT_CACHING 67
71
QUERY_TIMING 67
DEFAULT_LIKE_RANGE_SELECTIVITY
ORDER BY Clause 65
71
OS_FILE_CACHE_BUFFERING 22
EARLY_PREDICATE_EXECUTION 71
OS_FILE_CACHE_BUFFERING_TEMPDB 22
FLATTEN_SUBQUERIES 66
Overhead
IN_SUBQUERY_PREFERENCE 71
Buffer Cache 9
INDEX_PREFERENCE 71
IQ_USE_DIRECTIO 22
JOIN_ALGORITHM_PREFERENCE 71
P
JOIN_PREFERENCE 55 Page Size
MAX_CURSOR_COUNT 19 Block Size 12
MAX_HASH_ROWS 71 Data Compression 12
MAX_STATEMENT_COUNT 20 Default Size 12
OS_FILE_CACHE_BUFFERING 22 Determining 12
OS_FILE_CACHE_BUFFERING_TEMPDB Memory, Saving 12
22 Reducing Memory 12
PREFETCH_BUFFER_LIMIT 20 Paging 60
QUERY_ROWS_RETURNED_LIMIT 18 Paging and Disk Swapping 60
QUERY_TEMP_SPACE_LIMIT 17 Partitioned Table 55
SUBQUERY_CACHING_PREFERENCE 66 Partitions 24
SUBQUERY_FLATTENING_PERCENT 66 Peformance
SUBQUERY_FLATTENING_PREFERENC Monitoring And Tuning 28
E 66 performance
SWEEPER_THREADS_PERCENT 23 balancing I/O 24
USER_RESOURCE_RESERVATION 14 consideration 3
WASH_AREA_BUFFERS_PERCENT 23 definition 3
Options, Query Optimization designing for 3
AGGREGATION_ALGORITHM_ Performance
PREFERENCE 71 Choosing Correct Index Type 41
DEFAULT_HAVING_SELECTIVITY 71 Restricting Concurrent Queries 16
DEFAULT_LIKE_MATCH_SELECTIVITY Subqueries 66
71 Performance Problems, Isolating 59
DEFAULT_LIKE_RANGE_SELECTIVITY PREFETCH_BUFFER_LIMIT 20
71 Prefetched Cache Pages 20
EARLY_PREDICATE_EXECUTION 71 Prefetched Rows
IN_SUBQUERY_PREFERENCE 71 Controlling 21
INDEX_PREFERENCE 71 PRIMARY KEY 42
JOIN_ALGORITHM_PREFERENCE 71 Primary Keys 47
80 SAP Sybase IQ
Index
82 SAP Sybase IQ
Index
84 SAP Sybase IQ