Upload
others
View
6
Download
0
Embed Size (px)
Citation preview
Confidential © 2016 Actian Corporation1 Confidential © 2016 Actian Corporation
PSQL Tips & TricksFor Maintenance and Support
Linda AndersonManager, PSQL Sustaining Engineering
Actian User ConferenceOctober 2016
Confidential © 2016 Actian Corporation2
What’s New?
PSQL Tips & Tricks
What’s Old?
What’s Secret?
PS
QL
13
What’s Next?
Confidential © 2016 Actian Corporation3
What’s New?
■ AuditMaster 12
■ DataExchange 12
■ Automatic Defragmentation
■ New SQL Syntax
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation4
What’s New – AuditMaster 12 & Audit for PSQL-J
■ Support for auditing files with long owner names
■ New AM database format uses long owner name + encryption (no SQL Access)
■ Integration with PSQL security models secured via DEFAULTDB
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation5
What’s New – AuditMaster 12
■ AMViewer login is different depending on DEFAULTDB security
PSQL Tips & Tricks
Unsecured or Mixed Mode:
Database Mode:
Confidential © 2016 Actian Corporation6
What’s New – AuditMaster 12
■ Did you know AM supports “Undo Operation(s)”?
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation7
What’s New – Data Exchange 12
■ Compatible with PSQL v12
■ Rebranded for Actian
■ Reformatted and updated documentation
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation8
What’s New – Automatic Defragmentation
■ One hour after the setting is turned on, the engine begins File Discovery for defragmentation criteria:
• > 10MB
• > 15% Fragmented
• > 15% Unused Space
• > 5% Out of Order
■ Looks at files opened since the engine started.
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation9
What’s New – SQL Syntax
■ TOP clause supports dynamic parameter
■ CREATE/ALTER TABLE supports non-existing relative paths
PSQL Tips & Tricks
CREATE PROCEDURE TopTest (:howmany integer) RETURNS (LastName varchar(25)) AS
BEGIN
SELECT TOP :howmany last_name FROM student, person WHERE student.id = person.id;
END;
CALL TopTest (6);
In an application: SELECT TOP ? * FROM Person
create table t1 using '..\newpath\t1.mkd' (id identity, name char(20));
create table t2 using '.\subfolder\t2.mkd' (id identity, name char(20));
Confidential © 2016 Actian Corporation10
What’s New – SQL Syntax
■ CREATE INDEX … USING #
■ DROP TABLE IF EXISTS
PSQL Tips & Tricks
CREATE INDEX “Citizen-x” USING 3 ON Person (citizenship);
CREATE INDEX “abc” USING 2 IN DICTIONARY ON t1 (name);
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2 IN DICTIONARY;
Confidential © 2016 Actian Corporation11
What’s Next – PSQL 13
■ Database Schema Export/Import
■ New SQL Syntax
PSQL Tips & Tricks
PS
QL
13
Confidential © 2016 Actian Corporation12
What’s Next – PSQL 13
■ Database Schema Export/Import (aka DumpDB)
■ Primary Use Cases:
• Migrate a database from v1 to v2 metadata
• Export schema for review/maintenance/migration
• Duplicate a database with a set of empty data files
■ Demo Time!
PSQL Tips & Tricks
PS
QL
13
Confidential © 2016 Actian Corporation13
What’s Next – PSQL 13
■ New SQL Syntax: LIMIT with OFFSET
• Similar to MySQL & Sybase
• Comparable to ROW_NUMBER() <SQLServer>, rownum <Oracle>
• Provides ability to paginate
• Cannot be used in the same sub-statement as TOP
■ New SQL Syntax: ORDER BY in Expression Subquery
PSQL Tips & Tricks
PS
QL
13
Skip the first 10 rows, return the next 5:
SELECT * FROM Person LIMIT 5 OFFSET 10;
SELECT * FROM Person LIMIT 10,5;
Skip the first 10 rows, return all remaining rows:
SELECT * FROM Person LIMIT ALL OFFSET 10
select D.Name, (select top 1 Last_Name, Cumulative_GPA from Student S, Person P
where S.ID = P.ID and S.Major = D.Name order by Cumulative_GPA DESC)
from Dept D;
Confidential © 2016 Actian Corporation14
What’s Old?
■ Function Executor History
■ Query Plan Viewer
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation15
What’s Old – Function Executor History
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation16
What’s Old – Function Executor History
■ History Shows all the operations executed
■ Can Execute one or more operations, with a repeat count
■ Supports Export & Import of one or more operations
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation17
What’s Old - Query Plan Viewer
■ Captures the PSQL’s execution plan associated with queries as they are executed.
■ Applies to the current SQL session
■ For ODBC, can use registry settings:
PSQL Tips & Tricks
SET QRYPLANOUTPUT = ‘c:\ProgramData\Actian\PSQL\logs\queries.qpf’;
SET QRYPLANOUTPUT = NULL;
SET QRYPLAN = ON;
SET QRYPLAN = OFF;
Confidential © 2016 Actian Corporation18
What’s Old - Query Plan Viewer
PSQL Tips & Tricks
set qryplanoutput = 'c:\ProgramData\Actian\PSQL\demodata\demo.qpf';
select (select class.name from class where enrolls.class_id=class.id ) as classname,
person.*,enrolls.* from person,enrolls
where person.id=enrolls.student_id and last_name like 'c%'
order by last_name,classname;
Confidential © 2016 Actian Corporation19
What’s Secret?
■ Undocumented SQL Syntax
■ Undocumented Registry Settings
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation20
What’s Secret – Undocumented SQL Syntax
■ Create legacy data types in legacy files
■ Switch database context
PSQL Tips & Tricks
SET LEGACYTYPESALLOWED = ON;
SET TRUENULLCREATE = OFF;
CREATE TABLE oldtable (id identity, name lstring(10), misc note(8000));
USE MyDB;
SELECT * FROM T1;
USE DEMODATA;
SELECT * FROM Billing;
Confidential © 2016 Actian Corporation21
What’s Secret – Undocumented Registry Settings
■ Extended Operations Reject Count Override
• A large reject count could cause other threads in the engine to be blocked waiting for the Extended operation to finish.
• HKEY_LOCAL_MACHINE\SOFTWARE\Pervasive Software\MicroKernel Server Engine\Version 12\Settings
• Name: Reject Count
• Type: DWORD
• Values: 1-4095 (default is 4095)
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation22
What’s Secret – Undocumented Registry Settings
■ Optimize on Btrieve Null Keys
• SQL engine can use an index that corresponds to a Btrieve key using the Null attribute.
• HKEY_LOCAL_MACHINE\SOFTWARE\Pervasive Software\SQL Relational Engine
• Name: UseBtrieveExcludeNullKey
• Type: String
• Values: NO | YES
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation23
What’s Secret – Undocumented Registry Settings
■ Data Exchange: Make DX Operations Atomic
• Regulates if the updates/insert/deletes to the user tables and to the corresponding PDC tables are done as atomic operations (in a transaction).
• Use if DX introduces unexpected errors such as 84, 85, 78, etc.
• HKEY_LOCAL_MACHINE\SOFTWARE\Pervasive Software\Pervasive Replication\
• Name: MakeDXOpsAtomic
• Type: String
• Values: YES | NO
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation24
What’s Secret – Undocumented Registry Settings
■ SQL Engine: Maximum Number of Tables Cached per Databases
• SQL engine caches metadata information for each database, which can consume a large amount of memory
• In an environment with many active databases, with large numbers of tables, you may want to limit how much metadata is cached
• HKEY_LOCAL_MACHINE\SOFTWARE\Pervasive Software\SQL Relational Engine
• Name: MaxCachedTables
• Type: String
• Values: 1-4095; Default=1500
PSQL Tips & Tricks
Confidential © 2016 Actian Corporation25
Q & A
Confidential © 2016 Actian Corporation26
Thank You!
Confidential © 2016 Actian Corporation27
This document is for informational purposes only and is subject to change at any time without notice. The information in this document is proprietary to Actian and no part of this document may be reproduced, copied, or transmitted in any form or for any purpose without the express prior written permission of Actian.
This document is not intended to be binding upon Actian to any particular course of business, pricing, product strategy, and/or development. Actian assumes no responsibility for errors or omissions in this document. Actian shall have no liability for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. Actian does not warrant the accuracy or completeness of the information, text, graphics, links, or other items contained within this material. This document is provided without a warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.