langinstall  preupgrade

Chapter 8: Utility Commands Reference

optdiag

Description

Displays optimizer statistics or loads updated statistics into system tables. optdiag is located in $SYBASE/$SYBASE_ASE/bin.

Windows The utility is optdiag.exe, located in %SYBASE%\%SYBASE_ASE%\bin.

Syntax

optdiag [binary] [simulate] statistics
    { -i input_file |
        database[.owner[.[table[.column] ] ] ] [-o output_file] }
    [-U user_name]
    [-P password]
    [-T trace_value]
    [-I interfaces_file]
    [-S server]
    [-v]
    [-h]
    [-s]
    [-z language]
    [-J client_character_set]
    [-a display_charset]

Parameters

binary

extracts statistics in human-readable form and in binary form. When used with an input file (-i input_file), loads binary statistics into system tables.

simulate

specifies that optdiag display or load simulated statistics. See the Performance and Tuning Guide.

-i input_file

specifies the name of the operating system file to use for optdiag input. Specifying an input file causes optdiag to update optimizer statistics for the table or column by using the values in the specified file (also called “input mode”).

database

is the name of the database whose statistics you want displayed. In input mode, optdiag uses the database name as specified in the file, and does not accept a database name from the command line.

owner

is the name of a table owner.

table

is the name of the table to survey for statistics.

column

is the name of the colum to survey.

-o output_file

specifies the name of an operating system file to store the output from optdiag. If a file with the same name already exists, optdiag overwrites that file without warning.

-U user_name

specifies an Adaptive Server login name.

-P password

specifies your Adaptive Server password. If you do not specify the -P flag, optdiag prompts for a password.

-T trace_value

sets trace flags for the optdiag session. The optdiag trace flags are:

Flag value

Meaning

1

Do not stop with a warning if the optdiag version of Adaptive Server in use does not match the Adaptive Server version in the input file.

2

Display status message “Next table is table_name” when in input mode.

4

Skip consistency checking for step numbers while loading histograms in input mode.

6

Display lines of input file during input mode. This flag has no effect in display mode.

-I interfaces_file

specifies the name and location of the interfaces file to use when connecting to Adaptive Server.

If you do not use -I and specify an interfaces file name, optdiag looks for the interfaces file (interfaces in UNIX), in the directory specified by the SYBASE environment variable. In Windows, optdiag looks for a file named sql.ini in the ini subdirectory in the Sybase installation directory (d:\sybase). Then, if SYBASE is not set, optdiag looks for the file in the default $SYBASE directory (%SYBASE% in Windows).

-S server

specifies the name of the Adaptive Server to which to connect. optdiag looks for this name in the interfaces file (sql.ini in Windows).

-v

displays the version number of and a copyright message for optdiag and exits.

-h

displays the optdiag syntax help.

-s

includes system tables in optdiag output. By default, only user tables are included.

-z language

is the official name of an alternate language that the server uses both for date formats and to display optdiag prompts and messages. Without the -z flag, optdiag uses the server’s default language.

You can add languages to Adaptive Server either during or after installation, After Adaptive Server installation, use either the langinstall utility or the sp_addlanguage stored procedure to add a language.

-J client_charset

specifies the character set to use on the client. A filter converts input between client_charset and the Adaptive Server character set.

By using -J client_charset, you request that Adaptive Server convert data to and from client_charset, the client’s character set.

By using -J without a character set name, you specify character set conversion as NULL; no conversion takes place. Use this -J alone when the client and server are using the same character set.

By omitting -J, you set the character set to the default set for the platform. A filter converts input between the default set and the Adaptive Server character set. Keep in mind that the default may not necessarily be the character set that the client is using.

For more information about character sets and their associated flags, see the System Administration Guide.

-a display_charset

runs optdiag from a terminal with a character set that differs from that of the machine on which optdiag is running.

NoteThe ascii_7 character set is compatible with all character sets. If either the Adaptive Server character set or the client character set is set to ascii_7, any 7-bit ASCII character can pass unaltered between client and server. Any other characters produce conversion errors. For more information on character-set conversion, see the System Administration Guide.

NoteOn some Linux platforms, the LANG environment variable may be set by default to “en_US.UTF-8,” which can cause unnecessary LONGCHAR conversion between the client and server. If your server and client have different charsets, Sybase recommends that you bypass the conversion using one of these methods:

  • unsetenv LANG

  • setenv LANG C

  • optdiag -J

  • optdiag -Jiso-1 (if your server uses iso-1)

Examples

Example 1

Displays statistics for all user tables in the pubs2 database and places the output in the pubs2.opt file:

optdiag statistics pubs2 -Usa -Ppasswd -o pubs2.opt

Example 2

Displays statistics for the titles table:

optdiag statistics pubs2..titles -Usa -Ppasswd -o titles.opt

Example 3

Displays statistics using the roman8 character set and row labels and error messages in French:

optdiag statistics pubs2..titles -Usa -Ppasswd -o titles.opt -J roman8 
    -z french

Example 4

Displays binary statistics for the price column in the titles table:

optdiag binary statistics pubs2..titles.price -Usa -Ppasswd -o price.opt

Example 5

Loads edited statistics from the price.opt file:

optdiag statistics -i price.opt -Usa -Ppasswd

Usage


Byte ordering and binary optdiag files


Input mode

See also

For more information about the optdiag command and an explanation of the optdiag output, see the Performance and Tuning Guide.

For more information on changing statistics using optdiag, see the Performance and Tuning Guide.

Commands create index, delete statistics, set, update statistics

System procedures sp_addlogin, sp_configure, sp_defaultlanguage, sp_droplanguage, sp_flushstats, sp_helplanguage





Copyright © 2005. Sybase Inc. All rights reserved. preupgrade

View this book as PDF