SlideShare a Scribd company logo
www.firebase.com.br 1 © 2014 – Carlos H. Cantu 
Creating logs for data auditing 
Carlos H. Cantu 
www.firebase.com.br 
www.firebirdnews.org
www.firebase.com.br 2 © 2014 – Carlos H. Cantu 
Who am I? 
• 
Maintainer of www.firebase.com.br and www.firebirdnews.org 
• 
Author of 2 Firebird books published in Brazil 
• 
Software developer for about 30 years 
• 
Organizer of the Firebird Developers Day conference 
• 
Firebird consultant
www.firebase.com.br 3 © 2014 – Carlos H. Cantu 
Why logging? 
• 
To know what, when, who and where information was inserted, deleted or altered. 
• 
Technical information: transaction number, isolation, protocol, etc.. 
• 
Avoid (once for all) allegations like: 
– 
The record disappeared! 
– 
I didn’t change anything!
www.firebase.com.br 4 © 2014 – Carlos H. Cantu 
Proposed solution 
• 
Log routines implemented using native features of Firebird >= 2.1 (i.e.: PSQL, triggers and procedures). 
• 
Two log tables used: 
– 
Operations executed 
– 
Data associated with those operations 
• 
The creation and maintenance of the log triggers will be entire done by a single store procedure.
www.firebase.com.br 5 © 2014 – Carlos H. Cantu 
Log operations table structure 
CREATE TABLE LOG_OPERATIONS( 
IDLOGOPER BIGINT NOT NULL, --Primary key 
TABLE_NAME VARCHAR(31) NOT NULL COLLATE WIN_PTBR, 
OPERATION CHAR(1) NOT NULL, 
USER_NAME VARCHAR(64) COLLATE WIN_PTBR, 
SYSTIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP(0), 
TRANSACTIONID INTEGER, 
CLIENT_ADDRESS VARCHAR(255) COLLATE WIN_PTBR, 
NETWORK_PROTOCOL VARCHAR(255) COLLATE WIN_PTBR, 
TR_ISOLATION VARCHAR(255) COLLATE WIN_PTBR, 
PK1 VARCHAR(50) COLLATE WIN_PTBR, 
PK2 VARCHAR(50) COLLATE WIN_PTBR, 
PK3 VARCHAR(50) COLLATE WIN_PTBR 
);
www.firebase.com.br 6 © 2014 – Carlos H. Cantu 
Log data table 
CREATE TABLE LOG_DATA( 
ID BIGINT NOT NULL,--Primary key 
IDLOGOPER BIGINT NOT NULL, --Foreign key 
COLUMN_NAME VARCHAR(31) COLLATE WIN_PTBR, 
OLD_VALUE VARCHAR(2046) COLLATE WIN_PTBR, 
NEW_VALUE VARCHAR(2046) COLLATE WIN_PTBR, 
OLD_BLOB BLOB SUB_TYPE 0 SEGMENT SIZE 80, 
NEW_BLOB BLOB SUB_TYPE 0 SEGMENT SIZE 80 
);
www.firebase.com.br 7 © 2014 – Carlos H. Cantu 
Pay attention... 
• 
Rapid growing of the database file. 
• 
Performance of the operations. 
• 
Easy way to use the logged information. 
• 
Maintenance of the log routines in the case of changes in the metadata. 
• 
Blob columns. 
• 
Varchar columns. 
• 
Float or Double precision columns.
www.firebase.com.br 8 © 2014 – Carlos H. Cantu 
Rapid growing of the database file 
• 
Logged data occupies space in the database. 
• 
Tips: 
– 
Put the log in a separate database (speed up the production database backups, etc.). 
– 
Store the log database in another hard drive. 
– 
Purge of the old logs from time to time. 
– 
Transfer the old log data to archived files.
www.firebase.com.br 9 © 2014 – Carlos H. Cantu 
Operations performance 
• 
In normal usage conditions, the performance degradation is not noticed by the users. 
• 
Batch operations can show perceptible performance loss. 
• 
Take care of combination of FW = ON + Barrier active in Linux systems!
www.firebase.com.br 10 © 2014 – Carlos H. Cantu 
Easy way to use logged data 
• 
The logged information are stored in “normal” tables in the database, so they can be accessed using selects. 
• 
You can create user friendly GUI in your app, allowing users to make their own searches in the logged data.
www.firebase.com.br 11 © 2014 – Carlos H. Cantu 
Log routines maintenance 
• 
Any change in the database table’s metadata needs the log trigger of that table to be updated. 
• 
Updating the log trigger isquick and easy (ie: just run the procedure and it will recreate the log trigger).
www.firebase.com.br 12 © 2014 – Carlos H. Cantu 
Blob columns 
• 
Blob can has “any” size. 
• 
Null blobs occupies only a few bytes in the database page.
www.firebase.com.br 13 © 2014 – Carlos H. Cantu 
VARCHAR columns 
• 
Varchar and char columns are stored RLE compressed. 
• 
Content can vary from 1 to 32.767 (char) and 32.765 (varchar) “bytes”. 
• 
You can set a limit (trunc) to the size of char/varchars stored in the log tables.
www.firebase.com.br 14 © 2014 – Carlos H. Cantu 
Float or Double Precision columns 
• 
Take care with the precision! 
• 
The “string” version of the values may not be exactly equal to the original value (IEEE standard inherited “problem”). 
• 
Always when possible, prefer to use decimalor numeric(with dialect 3) to avoid inaccurate values problem.
www.firebase.com.br 15 © 2014 – Carlos H. Cantu 
Creation of the log triggers 
• 
DDL (Data Definition Language) statements are notdirect available inside procedures and/or triggers. 
• 
Solution: Use execute statement to run DDL statements. 
• 
Warning: There is a 64kb limitin the source code of procedures and triggers 
• 
Use IS DISTINCT FROM instead ofif ((new.afield<> old.afield) or ((new.afield is null) and (old.afield is not null)) or ((new.afieldis not null) and (old.afieldis null)))
www.firebase.com.br 16 © 2014 – Carlos H. Cantu 
Storing the log in external databases 
• 
Firebird >= 2.5 brought some enhancements to execute statement 
• 
It allows to access external databases! 
• 
EXECUTE STATEMENT <query_text> [(<input_parameters>)] [ON EXTERNAL[DATA SOURCE] <connection_string>] [WITH {AUTONOMOUS | COMMON} TRANSACTION] [AS USER <user_name>] [PASSWORD <password>] [ROLE <role_name>] [WITH CALLER PRIVILEGES] [INTO <variables>]
www.firebase.com.br 17 © 2014 – Carlos H. Cantu 
Example database
www.firebase.com.br 18 © 2014 – Carlos H. Cantu 
Benchmarks 
• 
Batch operations: 100.000 inserts20.000 updates10.000 deletes 
• 
Firebird 2.5.2 SS 
• 
Windows 8.1 Pro 64bits 
• 
Intel QuadCore+ 16GB RAM 
Obs: All operations were executed inside a single transaction.
www.firebase.com.br 19 © 2014 – Carlos H. Cantu 
Firebird 2.5.2 SuperServer 
• 
No logging (log inactive): Prepare time = 0msExecute time = 1m 30s 954msCurrent memory = 1.336.460Max memory = 2.214.544Memory buffers = 75Reads from disk to cache = 70.670Writes from cache to disk = 51.483Fetches from cache = 1.444.617 
• 
Logactive (Externallog DB): Prepare time = 0msExecute time = 2m 45s 141ms (1,83x increase) Current memory = 1.743.324Max memory = 2.620.112Memory buffers = 75Reads from disk to cache = 70.448Writes from cache to disk = 51.200Fetches from cache = 1.444.727
www.firebase.com.br 20 © 2014 – Carlos H. Cantu 
Firebird 2.5.2 SuperServer 
• 
log active (internal log tables) Prepare time = 0msExecute time = 4m 57s 375ms (3,3x increase) Current memory = 2.016.788Max memory = 3.191.832Memory buffers = 90Reads from disk to cache = 84.734Writes from cache to disk = 83.495Fetches from cache = 13.645.639Log DB size = ~118MB
www.firebase.com.br 21 © 2014 – Carlos H. Cantu 
Possible improvements 
• 
Allow to specify if want to log only inserts, deletes or updates (or a combination of them). 
• 
Use internal function rdb$get_contextto retrieve the logged user, instead of the connected user (current_user) 
• 
Reduce the name of the log procedures, to save bytes in the triggers source code.
www.firebase.com.br 22 © 2014 – Carlos H. Cantu 
Tips 
• 
In extreme cases, to increase log performance in batch operations, you can deactivate the indexes of the log tables before executing them, and activate them after it is finished 
• 
Connect to the external database using an “embedded” connection. 
• 
Configure the log database with the “-use full” option.
www.firebase.com.br 23 © 2014 – Carlos H. Cantu 
FIM 
Questions? 
www.firebase.com.br 
www.firebirdnews.org 
Download the scripts at http://www.firebase.com.br/fb/imgdocs/cantu_log_bds.zip 
ThankstoallConferencesponsors:

More Related Content

PDF
Understanding Numbers in Firebird SQL
PDF
Measuring Firebird Disk I/O
PDF
Native erasure coding support inside hdfs presentation
PPTX
Less is More: 2X Storage Efficiency with HDFS Erasure Coding
PPTX
RAIDZ on-disk format vs. small blocks
PPTX
Resolving Firebird performance problems
PDF
Hadoop operations basic
PDF
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab
Understanding Numbers in Firebird SQL
Measuring Firebird Disk I/O
Native erasure coding support inside hdfs presentation
Less is More: 2X Storage Efficiency with HDFS Erasure Coding
RAIDZ on-disk format vs. small blocks
Resolving Firebird performance problems
Hadoop operations basic
Introduction to SparkR | Big Data Hadoop Spark Tutorial | CloudxLab

What's hot (18)

PPT
Oracle real application_cluster
PDF
Hadoop - Lessons Learned
PPTX
Setting up a big data platform at kelkoo
PDF
2 technical-dns-workshop-day1
PPTX
In-memory Caching in HDFS: Lower Latency, Same Great Taste
PPTX
Hadoop architecture meetup
PDF
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
PDF
7 technical-dns-workshop-day3
PPT
Hadoop training in hyderabad-kellytechnologies
PPT
Hadoop Architecture
PPTX
Big data- HDFS(2nd presentation)
PPTX
Bucket your partitions wisely - Cassandra summit 2016
PDF
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
PDF
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
PDF
DNS Survival Guide
PPTX
Introduction to hadoop high availability
PPTX
Facebook's Approach to Big Data Storage Challenge
PPT
ha_module5
Oracle real application_cluster
Hadoop - Lessons Learned
Setting up a big data platform at kelkoo
2 technical-dns-workshop-day1
In-memory Caching in HDFS: Lower Latency, Same Great Taste
Hadoop architecture meetup
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
7 technical-dns-workshop-day3
Hadoop training in hyderabad-kellytechnologies
Hadoop Architecture
Big data- HDFS(2nd presentation)
Bucket your partitions wisely - Cassandra summit 2016
Obtaining the Perfect Smoke By Monitoring Your BBQ with InfluxDB and Telegraf
ClickHouse tips and tricks. Webinar slides. By Robert Hodges, Altinity CEO
DNS Survival Guide
Introduction to hadoop high availability
Facebook's Approach to Big Data Storage Challenge
ha_module5
Ad

Viewers also liked (9)

PDF
SuperServer in Firebird 3
ODP
How Firebird transactions work
ODP
Firebird 3: provider-based architecture, plugins and OO approach to API
PDF
Firebird 3 Windows Functions
PDF
Initial review of Firebird 3
PDF
Firebird
PDF
New SQL Features in Firebird 3, by Vlad Khorsun
ODP
Tips for using Firebird system tables
PDF
Life with big Firebird databases
SuperServer in Firebird 3
How Firebird transactions work
Firebird 3: provider-based architecture, plugins and OO approach to API
Firebird 3 Windows Functions
Initial review of Firebird 3
Firebird
New SQL Features in Firebird 3, by Vlad Khorsun
Tips for using Firebird system tables
Life with big Firebird databases
Ad

Similar to Creating logs for data auditing in FirebirdSQL (20)

PDF
EnterpriseDB BackUp and Recovery Tool
 
PPTX
Hadoop Operations - Best Practices from the Field
PPTX
Hadoop operations-2015-hadoop-summit-san-jose-v5
PPT
16aug06.ppt
PDF
LBNL Node Health Check Update
PDF
High Performance With Java
PPTX
Managing Memory & Locks - Series 1 Memory Management
PDF
Chronix Poster for the Poster Session FAST 2017
PPTX
MongoDB Days UK: Tales from the Field
PPTX
Progress OE performance management
PPTX
Progress Openedge performance management
PPTX
Main Memory
PDF
Sql server tips from the field
PPTX
Postgres in production.2014
 
PDF
MySQL Performance Metrics that Matter
PDF
SDAccel Design Contest: Vivado HLS
PPTX
Database Dumps and Backups
 
PDF
Still All on One Server: Perforce at Scale
PDF
Backup Options for IBM PureData for Analytics powered by Netezza
PPTX
High performance computing capacity building
EnterpriseDB BackUp and Recovery Tool
 
Hadoop Operations - Best Practices from the Field
Hadoop operations-2015-hadoop-summit-san-jose-v5
16aug06.ppt
LBNL Node Health Check Update
High Performance With Java
Managing Memory & Locks - Series 1 Memory Management
Chronix Poster for the Poster Session FAST 2017
MongoDB Days UK: Tales from the Field
Progress OE performance management
Progress Openedge performance management
Main Memory
Sql server tips from the field
Postgres in production.2014
 
MySQL Performance Metrics that Matter
SDAccel Design Contest: Vivado HLS
Database Dumps and Backups
 
Still All on One Server: Perforce at Scale
Backup Options for IBM PureData for Analytics powered by Netezza
High performance computing capacity building

More from Mind The Firebird (20)

PDF
Using Azure cloud and Firebird to develop applications easily
PDF
A year in the life of Firebird .Net provider
ODP
Copycat presentation
ODP
Using ТРСС to study Firebird performance
ODP
Overview of RedDatabase 2.5
ODP
Firebird Performance counters in details
PPTX
Threading through InterBase, Firebird, and beyond
PPTX
Orphans, Corruption, Careful Write, and Logging
ODP
Firebird release strategy and roadmap for 2015/2016
PPTX
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...
PDF
Working with Large Firebird databases
PDF
Stored procedures in Firebird
PDF
Firebird on Linux
PPTX
Superchaging big production systems on Firebird: transactions, garbage, maint...
PDF
Firebird meets NoSQL
PDF
Continuous Database Monitoring with the Trace API
PDF
Firebird Conference 2011 - Introduction
PPTX
Firebird database recovery and protection for enterprises and ISV
PPTX
Migration from Firebird 1.5 to Firebird 2.5
PPT
A Bird and the Web
Using Azure cloud and Firebird to develop applications easily
A year in the life of Firebird .Net provider
Copycat presentation
Using ТРСС to study Firebird performance
Overview of RedDatabase 2.5
Firebird Performance counters in details
Threading through InterBase, Firebird, and beyond
Orphans, Corruption, Careful Write, and Logging
Firebird release strategy and roadmap for 2015/2016
Nbackup and Backup: Internals, Usage strategy and Pitfalls, by Dmitry Kuzmenk...
Working with Large Firebird databases
Stored procedures in Firebird
Firebird on Linux
Superchaging big production systems on Firebird: transactions, garbage, maint...
Firebird meets NoSQL
Continuous Database Monitoring with the Trace API
Firebird Conference 2011 - Introduction
Firebird database recovery and protection for enterprises and ISV
Migration from Firebird 1.5 to Firebird 2.5
A Bird and the Web

Recently uploaded (20)

PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
System and Network Administraation Chapter 3
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Digital Strategies for Manufacturing Companies
PPTX
L1 - Introduction to python Backend.pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Introduction to Artificial Intelligence
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
history of c programming in notes for students .pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Odoo POS Development Services by CandidRoot Solutions
System and Network Administraation Chapter 3
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PTS Company Brochure 2025 (1).pdf.......
Operating system designcfffgfgggggggvggggggggg
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Digital Strategies for Manufacturing Companies
L1 - Introduction to python Backend.pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Introduction to Artificial Intelligence
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Navsoft: AI-Powered Business Solutions & Custom Software Development
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
history of c programming in notes for students .pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
2025 Textile ERP Trends: SAP, Odoo & Oracle
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

Creating logs for data auditing in FirebirdSQL

  • 1. www.firebase.com.br 1 © 2014 – Carlos H. Cantu Creating logs for data auditing Carlos H. Cantu www.firebase.com.br www.firebirdnews.org
  • 2. www.firebase.com.br 2 © 2014 – Carlos H. Cantu Who am I? • Maintainer of www.firebase.com.br and www.firebirdnews.org • Author of 2 Firebird books published in Brazil • Software developer for about 30 years • Organizer of the Firebird Developers Day conference • Firebird consultant
  • 3. www.firebase.com.br 3 © 2014 – Carlos H. Cantu Why logging? • To know what, when, who and where information was inserted, deleted or altered. • Technical information: transaction number, isolation, protocol, etc.. • Avoid (once for all) allegations like: – The record disappeared! – I didn’t change anything!
  • 4. www.firebase.com.br 4 © 2014 – Carlos H. Cantu Proposed solution • Log routines implemented using native features of Firebird >= 2.1 (i.e.: PSQL, triggers and procedures). • Two log tables used: – Operations executed – Data associated with those operations • The creation and maintenance of the log triggers will be entire done by a single store procedure.
  • 5. www.firebase.com.br 5 © 2014 – Carlos H. Cantu Log operations table structure CREATE TABLE LOG_OPERATIONS( IDLOGOPER BIGINT NOT NULL, --Primary key TABLE_NAME VARCHAR(31) NOT NULL COLLATE WIN_PTBR, OPERATION CHAR(1) NOT NULL, USER_NAME VARCHAR(64) COLLATE WIN_PTBR, SYSTIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP(0), TRANSACTIONID INTEGER, CLIENT_ADDRESS VARCHAR(255) COLLATE WIN_PTBR, NETWORK_PROTOCOL VARCHAR(255) COLLATE WIN_PTBR, TR_ISOLATION VARCHAR(255) COLLATE WIN_PTBR, PK1 VARCHAR(50) COLLATE WIN_PTBR, PK2 VARCHAR(50) COLLATE WIN_PTBR, PK3 VARCHAR(50) COLLATE WIN_PTBR );
  • 6. www.firebase.com.br 6 © 2014 – Carlos H. Cantu Log data table CREATE TABLE LOG_DATA( ID BIGINT NOT NULL,--Primary key IDLOGOPER BIGINT NOT NULL, --Foreign key COLUMN_NAME VARCHAR(31) COLLATE WIN_PTBR, OLD_VALUE VARCHAR(2046) COLLATE WIN_PTBR, NEW_VALUE VARCHAR(2046) COLLATE WIN_PTBR, OLD_BLOB BLOB SUB_TYPE 0 SEGMENT SIZE 80, NEW_BLOB BLOB SUB_TYPE 0 SEGMENT SIZE 80 );
  • 7. www.firebase.com.br 7 © 2014 – Carlos H. Cantu Pay attention... • Rapid growing of the database file. • Performance of the operations. • Easy way to use the logged information. • Maintenance of the log routines in the case of changes in the metadata. • Blob columns. • Varchar columns. • Float or Double precision columns.
  • 8. www.firebase.com.br 8 © 2014 – Carlos H. Cantu Rapid growing of the database file • Logged data occupies space in the database. • Tips: – Put the log in a separate database (speed up the production database backups, etc.). – Store the log database in another hard drive. – Purge of the old logs from time to time. – Transfer the old log data to archived files.
  • 9. www.firebase.com.br 9 © 2014 – Carlos H. Cantu Operations performance • In normal usage conditions, the performance degradation is not noticed by the users. • Batch operations can show perceptible performance loss. • Take care of combination of FW = ON + Barrier active in Linux systems!
  • 10. www.firebase.com.br 10 © 2014 – Carlos H. Cantu Easy way to use logged data • The logged information are stored in “normal” tables in the database, so they can be accessed using selects. • You can create user friendly GUI in your app, allowing users to make their own searches in the logged data.
  • 11. www.firebase.com.br 11 © 2014 – Carlos H. Cantu Log routines maintenance • Any change in the database table’s metadata needs the log trigger of that table to be updated. • Updating the log trigger isquick and easy (ie: just run the procedure and it will recreate the log trigger).
  • 12. www.firebase.com.br 12 © 2014 – Carlos H. Cantu Blob columns • Blob can has “any” size. • Null blobs occupies only a few bytes in the database page.
  • 13. www.firebase.com.br 13 © 2014 – Carlos H. Cantu VARCHAR columns • Varchar and char columns are stored RLE compressed. • Content can vary from 1 to 32.767 (char) and 32.765 (varchar) “bytes”. • You can set a limit (trunc) to the size of char/varchars stored in the log tables.
  • 14. www.firebase.com.br 14 © 2014 – Carlos H. Cantu Float or Double Precision columns • Take care with the precision! • The “string” version of the values may not be exactly equal to the original value (IEEE standard inherited “problem”). • Always when possible, prefer to use decimalor numeric(with dialect 3) to avoid inaccurate values problem.
  • 15. www.firebase.com.br 15 © 2014 – Carlos H. Cantu Creation of the log triggers • DDL (Data Definition Language) statements are notdirect available inside procedures and/or triggers. • Solution: Use execute statement to run DDL statements. • Warning: There is a 64kb limitin the source code of procedures and triggers • Use IS DISTINCT FROM instead ofif ((new.afield<> old.afield) or ((new.afield is null) and (old.afield is not null)) or ((new.afieldis not null) and (old.afieldis null)))
  • 16. www.firebase.com.br 16 © 2014 – Carlos H. Cantu Storing the log in external databases • Firebird >= 2.5 brought some enhancements to execute statement • It allows to access external databases! • EXECUTE STATEMENT <query_text> [(<input_parameters>)] [ON EXTERNAL[DATA SOURCE] <connection_string>] [WITH {AUTONOMOUS | COMMON} TRANSACTION] [AS USER <user_name>] [PASSWORD <password>] [ROLE <role_name>] [WITH CALLER PRIVILEGES] [INTO <variables>]
  • 17. www.firebase.com.br 17 © 2014 – Carlos H. Cantu Example database
  • 18. www.firebase.com.br 18 © 2014 – Carlos H. Cantu Benchmarks • Batch operations: 100.000 inserts20.000 updates10.000 deletes • Firebird 2.5.2 SS • Windows 8.1 Pro 64bits • Intel QuadCore+ 16GB RAM Obs: All operations were executed inside a single transaction.
  • 19. www.firebase.com.br 19 © 2014 – Carlos H. Cantu Firebird 2.5.2 SuperServer • No logging (log inactive): Prepare time = 0msExecute time = 1m 30s 954msCurrent memory = 1.336.460Max memory = 2.214.544Memory buffers = 75Reads from disk to cache = 70.670Writes from cache to disk = 51.483Fetches from cache = 1.444.617 • Logactive (Externallog DB): Prepare time = 0msExecute time = 2m 45s 141ms (1,83x increase) Current memory = 1.743.324Max memory = 2.620.112Memory buffers = 75Reads from disk to cache = 70.448Writes from cache to disk = 51.200Fetches from cache = 1.444.727
  • 20. www.firebase.com.br 20 © 2014 – Carlos H. Cantu Firebird 2.5.2 SuperServer • log active (internal log tables) Prepare time = 0msExecute time = 4m 57s 375ms (3,3x increase) Current memory = 2.016.788Max memory = 3.191.832Memory buffers = 90Reads from disk to cache = 84.734Writes from cache to disk = 83.495Fetches from cache = 13.645.639Log DB size = ~118MB
  • 21. www.firebase.com.br 21 © 2014 – Carlos H. Cantu Possible improvements • Allow to specify if want to log only inserts, deletes or updates (or a combination of them). • Use internal function rdb$get_contextto retrieve the logged user, instead of the connected user (current_user) • Reduce the name of the log procedures, to save bytes in the triggers source code.
  • 22. www.firebase.com.br 22 © 2014 – Carlos H. Cantu Tips • In extreme cases, to increase log performance in batch operations, you can deactivate the indexes of the log tables before executing them, and activate them after it is finished • Connect to the external database using an “embedded” connection. • Configure the log database with the “-use full” option.
  • 23. www.firebase.com.br 23 © 2014 – Carlos H. Cantu FIM Questions? www.firebase.com.br www.firebirdnews.org Download the scripts at http://www.firebase.com.br/fb/imgdocs/cantu_log_bds.zip ThankstoallConferencesponsors: