SlideShare uma empresa Scribd logo
1 de 45
SQLite 3
  Scott MacVicar
PHP Barcelona 2008
Who Am I?


• Employed by Jelsoft Enterprises Ltd
• PHP (SQLite3, imagick, svn)
• GD
Overview

• What is SQLite?
• Why use SQLite?
• Who uses SQLite?
• SQLite Explained
• Difference between SQLite 2 and 3
• PDO / SQLite3
What is SQLite?

• Embedded SQL Database Engine
• Serverless - accesses disk directly
• Single file
• Cross Platform / Architecture
• Small footprint
• Manifest typing
Why use SQLite?


• Zero Configuration
• Portable
• Public Domain
Public Domain?


May you do good and not evil.

May you find forgiveness for yourself and forgive others.

May you share freely, never taking more than you give.
¿Public Domain?
Big SQLite Users



                                            •   Lightroom

                                            •   AIR


sqlite3 ~/Pictures/Lightroom/Lightroom Library.aglib
Big SQLite Users

•   Mail

•   Safari

•   Aperture

•   Core Data

•   iPhone
             sqlite3 ~/Library/Mail/Envelope Index
             sqlite3 ~/Library/Caches/com.apple.Safari/Cache.db
             sqlite3 ~/Pictures/Aperture Library.aplibrary/Aperture.aplib
Big SQLite Users



           •   Gears

           •   Android
Big SQLite Users




•   Virus Information
Big SQLite Users


           •   History

           •   Bookmarks

           •   Downloads
Big SQLite Users




•   Metadata
Where can SQLite be used?

• Replacement for a custom file format
• Temporary data storage (Unit Tests) - :memory:
• Alternative to enterprise DB for demo
• Local node storage
• Communication between apps
• Embedded Devices
Versions


• SQLite - 2.8.17
• PDO - 3.3.7 + 2.8.17   (3.6.2 in PHP 5.3)

• SQLite3 - 3.6.2, minimum is 3.3.9
SQLite 3
•   64-bit Rowids            •   Connections shared
                                 between threads
•   BLOB support
                             •   Runtime loadable
•   Improved concurrency         extensions

•   UTF-16 / UTF-8           •   Fulltext searching

•   User defined collations   •   ICU support

•   Named bound              •   OS Interface
    parameters
SQLite v2

• Smaller subset of SQL supported
• Larger file format
• Database format incompatible with v3
• No Unicode support
• No reading while writing
Examples


• Firefox 3.0
  • Profile directory contains places.sqlite
  • Schema on the next page
• iPhone SMS
Firefox Places Schema
PDO
SQLite3
Live Demo (Hopefully)
iPhone SMS Schema




 /private/var/root/Library/SMS/sms.db
 ~/Library/Application Support/MobileSync/Backup
Custom Functions


• Define SQL Functions in PHP
• Implement missing features
• Aggregation functions
Function Example
Custom Collations

•   Sorting in alphabetical   ☹   ☺
    order
                              a   a
•   ICU also provides this    i   é
    functionality
                              u   i
•   Use createCollation to    é   ó
    define comparison          ó   u
    function
Fulltext Indexing
Fulltext Searching
SQLite3 Extension

        SQLite3        SQLite3Stmt
open              paramCount
close             close
exec              execute
version           reset
lastInsertRowID   clear
loadExtension     bindValue
escapeString      bindParam
prepare
query
createFunction
createAggregate
lastErrorMsg
SQLite3 Extension

   SQLite3Result
fetchArray
reset
finalize
columnType
columnName
numColumns
Improving Performance

• Pragma
  • cache_size
  • fullfsync
  • synchronous
• Shared Cache
• Use Transactions
Benchmarks


•   Dual Xeon 3.2GHz,
    2GB RAM, Centos 5

•   MySQL vs SQLite

•   Synthetic Benchmark -
    YMMV
                            Original Image by Ben McLeod
Benchmarks - Tests

• 15 tests
• INSERT
• SELECT
• UPDATE
• DELETE
• DROP
Benchmarks - Insert
                          MySQL
10.0                      SQLite 2
                          SQLite 3
 7.5                      SQLite 3 (nosync)

 5.0

 2.5

  0
        Test 1   Test 2
Benchmarks - Select
                          MySQL
10.0                      SQLite 2
                          SQLite 3
 7.5                      SQLite 3 (nosync)

 5.0

 2.5

  0
        Test 3   Test 4
Benchmarks - Indices
                         MySQL
1.2                      SQLite 2
                         SQLite 3
0.9                      SQLite 3 (nosync)

0.6

0.3

 0
       Test 5   Test 6
Benchmarks - Update
                                   MySQL
5.00                               SQLite 2
                                   SQLite 3
3.75                               SQLite 3 (nosync)

2.50

1.25

  0
        Test 7   Test 8   Test 9
Benchmarks - Delete
                                        MySQL
2.0                                     SQLite 2
                                        SQLite 3
1.6
                                        SQLite 3 (nosync)
1.2

0.8

0.4

 0
      Test 11   Test 12   Test 13   Test 14
Benchmarks - Summary


• SQLite 3 is faster in almost every test
• Using MyISAM would show faster results
• Doesn’t test concurrency
Converting from MySQL

• varchar, char -> text
• smallint, tinyint, int -> integer
• auto_increment -> autoincrement
• unknown types converted to text
• MySQLi functions have SQLite3 equivalents
Unsupported SQL - Examples




                Original Image by Clive Arundell
Limitations

• Very large datasets
• High concurrency
• No Foreign Keys
• Nested Transactions
• Writing to Views
Miscellaneous


•   Integrity Check

•   Reclaim Unused Space

•   Backup
Tools - SQLite Manager
Resources

• http://www.sqlite.org
• http://www.php.net/sqlite3
• http://pecl.php.net/sqlite3
• http://talks.macvicar.net
• https://addons.mozilla.org/en-US/firefox/
 addon/5817

Mais conteúdo relacionado

Mais procurados

SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands1keydata
 
SQL Queries
SQL QueriesSQL Queries
SQL QueriesNilt1234
 
How To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | EdurekaHow To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | EdurekaEdureka!
 
android sqlite
android sqliteandroid sqlite
android sqliteDeepa Rani
 
SQLite3
SQLite3SQLite3
SQLite3cltru
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling sharqiyem
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code firstConfiz
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamentalvarunbhatt23
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Punjab University
 

Mais procurados (20)

Sql Functions And Procedures
Sql Functions And ProceduresSql Functions And Procedures
Sql Functions And Procedures
 
Getting Started with SQLite
Getting Started with SQLiteGetting Started with SQLite
Getting Started with SQLite
 
Introduction to Visual Studio.NET
Introduction to Visual Studio.NETIntroduction to Visual Studio.NET
Introduction to Visual Studio.NET
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
Database testing
Database testingDatabase testing
Database testing
 
Java Basics
Java BasicsJava Basics
Java Basics
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
How To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | EdurekaHow To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | Edureka
 
android sqlite
android sqliteandroid sqlite
android sqlite
 
SQLite3
SQLite3SQLite3
SQLite3
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
C# basics
 C# basics C# basics
C# basics
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
Mysql
MysqlMysql
Mysql
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamental
 
SQL
SQLSQL
SQL
 
SQL
SQLSQL
SQL
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 

Destaque

SQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management SystemSQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management SystemTanner Jessel
 
Introduction4 SQLite
Introduction4 SQLiteIntroduction4 SQLite
Introduction4 SQLiteStanley Huang
 
SQLite Techniques
SQLite TechniquesSQLite Techniques
SQLite Techniquesjoaopmaia
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1Warawut
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-FrontendsAccess ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-FrontendsPeter Eisentraut
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3Raghu nath
 
(140625) #fitalk sq lite 소개와 구조 분석
(140625) #fitalk   sq lite 소개와 구조 분석(140625) #fitalk   sq lite 소개와 구조 분석
(140625) #fitalk sq lite 소개와 구조 분석INSIGHT FORENSIC
 
In01 - Programmation Android - 05 - Google map
In01 - Programmation Android - 05 - Google mapIn01 - Programmation Android - 05 - Google map
In01 - Programmation Android - 05 - Google mapYann Caron
 
In01 - Programmation Android - 03 - HMI
In01 - Programmation Android - 03 - HMIIn01 - Programmation Android - 03 - HMI
In01 - Programmation Android - 03 - HMIYann Caron
 
Python sqlite3 - flask
Python   sqlite3 - flaskPython   sqlite3 - flask
Python sqlite3 - flaskEueung Mulyana
 
Sqlite3 command reference
Sqlite3 command referenceSqlite3 command reference
Sqlite3 command referenceRaghu nath
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Threeamiable_indian
 

Destaque (20)

SQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management SystemSQLite: Light, Open Source Relational Database Management System
SQLite: Light, Open Source Relational Database Management System
 
Introduction4 SQLite
Introduction4 SQLiteIntroduction4 SQLite
Introduction4 SQLite
 
Python sqlite3
Python sqlite3Python sqlite3
Python sqlite3
 
SQLite Techniques
SQLite TechniquesSQLite Techniques
SQLite Techniques
 
Sqlite
SqliteSqlite
Sqlite
 
SQLite
SQLiteSQLite
SQLite
 
Object-Oriented Programming 1
Object-Oriented Programming 1Object-Oriented Programming 1
Object-Oriented Programming 1
 
SQLite
SQLiteSQLite
SQLite
 
Access ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-FrontendsAccess ohne Access: Freie Datenbank-Frontends
Access ohne Access: Freie Datenbank-Frontends
 
Advance sqlite3
Advance sqlite3Advance sqlite3
Advance sqlite3
 
(140625) #fitalk sq lite 소개와 구조 분석
(140625) #fitalk   sq lite 소개와 구조 분석(140625) #fitalk   sq lite 소개와 구조 분석
(140625) #fitalk sq lite 소개와 구조 분석
 
Sq lite presentation
Sq lite presentationSq lite presentation
Sq lite presentation
 
In01 - Programmation Android - 05 - Google map
In01 - Programmation Android - 05 - Google mapIn01 - Programmation Android - 05 - Google map
In01 - Programmation Android - 05 - Google map
 
In01 - Programmation Android - 03 - HMI
In01 - Programmation Android - 03 - HMIIn01 - Programmation Android - 03 - HMI
In01 - Programmation Android - 03 - HMI
 
Python sqlite3 - flask
Python   sqlite3 - flaskPython   sqlite3 - flask
Python sqlite3 - flask
 
Aula 06 - TEP - Introdução SQLite
Aula 06 - TEP - Introdução SQLiteAula 06 - TEP - Introdução SQLite
Aula 06 - TEP - Introdução SQLite
 
Sqlite3 command reference
Sqlite3 command referenceSqlite3 command reference
Sqlite3 command reference
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
HDMI
HDMIHDMI
HDMI
 
SQLite
SQLiteSQLite
SQLite
 

Semelhante a SQLite 3 Explained by Scott MacVicar at PHP Barcelona 2008

ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performancerudib
 
Database automated build and test - SQL In The City Cambridge
Database automated build and test - SQL In The City CambridgeDatabase automated build and test - SQL In The City Cambridge
Database automated build and test - SQL In The City CambridgeRed Gate Software
 
MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015Mario Beck
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group ReplicationDave Stokes
 
My sql 56_roadmap_april2012
My sql 56_roadmap_april2012My sql 56_roadmap_april2012
My sql 56_roadmap_april2012sqlhjalp
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACKristofferson A
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017Dave Stokes
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for AndroidJakir Hossain
 
What's New in MySQL 5.7
What's New in MySQL 5.7What's New in MySQL 5.7
What's New in MySQL 5.7Olivier DASINI
 
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines SlidesMySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines SlidesSeveralnines
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesDave Stokes
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)Aurimas Mikalauskas
 
OpenSUSE Conf 2020 MySQL Clone
OpenSUSE Conf 2020 MySQL CloneOpenSUSE Conf 2020 MySQL Clone
OpenSUSE Conf 2020 MySQL CloneGeorgi Kodinov
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlsqlhjalp
 
Developing on SQL Azure
Developing on SQL AzureDeveloping on SQL Azure
Developing on SQL AzureIke Ellis
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performanceEngine Yard
 
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Ivan Ma
 

Semelhante a SQLite 3 Explained by Scott MacVicar at PHP Barcelona 2008 (20)

ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performance
 
Qure Tech Presentation
Qure Tech PresentationQure Tech Presentation
Qure Tech Presentation
 
Database automated build and test - SQL In The City Cambridge
Database automated build and test - SQL In The City CambridgeDatabase automated build and test - SQL In The City Cambridge
Database automated build and test - SQL In The City Cambridge
 
MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015MySQL 5.7: What's New, Nov. 2015
MySQL 5.7: What's New, Nov. 2015
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group Replication
 
My sql 56_roadmap_april2012
My sql 56_roadmap_april2012My sql 56_roadmap_april2012
My sql 56_roadmap_april2012
 
Nadzor sql a
Nadzor sql aNadzor sql a
Nadzor sql a
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
Data Handning with Sqlite for Android
Data Handning with Sqlite for AndroidData Handning with Sqlite for Android
Data Handning with Sqlite for Android
 
What's New in MySQL 5.7
What's New in MySQL 5.7What's New in MySQL 5.7
What's New in MySQL 5.7
 
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines SlidesMySQL Cluster 7.3 Performance Tuning - Severalnines Slides
MySQL Cluster 7.3 Performance Tuning - Severalnines Slides
 
Confoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New FeaturesConfoo 2021 -- MySQL New Features
Confoo 2021 -- MySQL New Features
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
MySQL Aquarium Paris
MySQL Aquarium ParisMySQL Aquarium Paris
MySQL Aquarium Paris
 
OpenSUSE Conf 2020 MySQL Clone
OpenSUSE Conf 2020 MySQL CloneOpenSUSE Conf 2020 MySQL Clone
OpenSUSE Conf 2020 MySQL Clone
 
My sql crashcourse_intro_kdl
My sql crashcourse_intro_kdlMy sql crashcourse_intro_kdl
My sql crashcourse_intro_kdl
 
Developing on SQL Azure
Developing on SQL AzureDeveloping on SQL Azure
Developing on SQL Azure
 
6 tips for improving ruby performance
6 tips for improving ruby performance6 tips for improving ruby performance
6 tips for improving ruby performance
 
Exploring mysql cluster 7.4
Exploring mysql cluster 7.4Exploring mysql cluster 7.4
Exploring mysql cluster 7.4
 

Mais de Scott MacVicar

Caching for Cash: Caching
Caching for Cash: CachingCaching for Cash: Caching
Caching for Cash: CachingScott MacVicar
 
Caching for Cash: Benchmarking and Profiling
Caching for Cash: Benchmarking and ProfilingCaching for Cash: Benchmarking and Profiling
Caching for Cash: Benchmarking and ProfilingScott MacVicar
 
How to write PHPT tests
How to write PHPT testsHow to write PHPT tests
How to write PHPT testsScott MacVicar
 

Mais de Scott MacVicar (7)

Alternative Databases
Alternative DatabasesAlternative Databases
Alternative Databases
 
Caching for Cash: Caching
Caching for Cash: CachingCaching for Cash: Caching
Caching for Cash: Caching
 
Caching for Cash: Benchmarking and Profiling
Caching for Cash: Benchmarking and ProfilingCaching for Cash: Benchmarking and Profiling
Caching for Cash: Benchmarking and Profiling
 
PHP 5.3 + Windows
PHP 5.3 + WindowsPHP 5.3 + Windows
PHP 5.3 + Windows
 
PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
Alternative Databases
Alternative DatabasesAlternative Databases
Alternative Databases
 
How to write PHPT tests
How to write PHPT testsHow to write PHPT tests
How to write PHPT tests
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

SQLite 3 Explained by Scott MacVicar at PHP Barcelona 2008

  • 1. SQLite 3 Scott MacVicar PHP Barcelona 2008
  • 2. Who Am I? • Employed by Jelsoft Enterprises Ltd • PHP (SQLite3, imagick, svn) • GD
  • 3. Overview • What is SQLite? • Why use SQLite? • Who uses SQLite? • SQLite Explained • Difference between SQLite 2 and 3 • PDO / SQLite3
  • 4. What is SQLite? • Embedded SQL Database Engine • Serverless - accesses disk directly • Single file • Cross Platform / Architecture • Small footprint • Manifest typing
  • 5. Why use SQLite? • Zero Configuration • Portable • Public Domain
  • 6. Public Domain? May you do good and not evil. May you find forgiveness for yourself and forgive others. May you share freely, never taking more than you give.
  • 8. Big SQLite Users • Lightroom • AIR sqlite3 ~/Pictures/Lightroom/Lightroom Library.aglib
  • 9. Big SQLite Users • Mail • Safari • Aperture • Core Data • iPhone sqlite3 ~/Library/Mail/Envelope Index sqlite3 ~/Library/Caches/com.apple.Safari/Cache.db sqlite3 ~/Pictures/Aperture Library.aplibrary/Aperture.aplib
  • 10. Big SQLite Users • Gears • Android
  • 11. Big SQLite Users • Virus Information
  • 12. Big SQLite Users • History • Bookmarks • Downloads
  • 14. Where can SQLite be used? • Replacement for a custom file format • Temporary data storage (Unit Tests) - :memory: • Alternative to enterprise DB for demo • Local node storage • Communication between apps • Embedded Devices
  • 15. Versions • SQLite - 2.8.17 • PDO - 3.3.7 + 2.8.17 (3.6.2 in PHP 5.3) • SQLite3 - 3.6.2, minimum is 3.3.9
  • 16. SQLite 3 • 64-bit Rowids • Connections shared between threads • BLOB support • Runtime loadable • Improved concurrency extensions • UTF-16 / UTF-8 • Fulltext searching • User defined collations • ICU support • Named bound • OS Interface parameters
  • 17. SQLite v2 • Smaller subset of SQL supported • Larger file format • Database format incompatible with v3 • No Unicode support • No reading while writing
  • 18. Examples • Firefox 3.0 • Profile directory contains places.sqlite • Schema on the next page • iPhone SMS
  • 20. PDO
  • 23. iPhone SMS Schema /private/var/root/Library/SMS/sms.db ~/Library/Application Support/MobileSync/Backup
  • 24. Custom Functions • Define SQL Functions in PHP • Implement missing features • Aggregation functions
  • 26. Custom Collations • Sorting in alphabetical ☹ ☺ order a a • ICU also provides this i é functionality u i • Use createCollation to é ó define comparison ó u function
  • 29. SQLite3 Extension SQLite3 SQLite3Stmt open paramCount close close exec execute version reset lastInsertRowID clear loadExtension bindValue escapeString bindParam prepare query createFunction createAggregate lastErrorMsg
  • 30. SQLite3 Extension SQLite3Result fetchArray reset finalize columnType columnName numColumns
  • 31. Improving Performance • Pragma • cache_size • fullfsync • synchronous • Shared Cache • Use Transactions
  • 32. Benchmarks • Dual Xeon 3.2GHz, 2GB RAM, Centos 5 • MySQL vs SQLite • Synthetic Benchmark - YMMV Original Image by Ben McLeod
  • 33. Benchmarks - Tests • 15 tests • INSERT • SELECT • UPDATE • DELETE • DROP
  • 34. Benchmarks - Insert MySQL 10.0 SQLite 2 SQLite 3 7.5 SQLite 3 (nosync) 5.0 2.5 0 Test 1 Test 2
  • 35. Benchmarks - Select MySQL 10.0 SQLite 2 SQLite 3 7.5 SQLite 3 (nosync) 5.0 2.5 0 Test 3 Test 4
  • 36. Benchmarks - Indices MySQL 1.2 SQLite 2 SQLite 3 0.9 SQLite 3 (nosync) 0.6 0.3 0 Test 5 Test 6
  • 37. Benchmarks - Update MySQL 5.00 SQLite 2 SQLite 3 3.75 SQLite 3 (nosync) 2.50 1.25 0 Test 7 Test 8 Test 9
  • 38. Benchmarks - Delete MySQL 2.0 SQLite 2 SQLite 3 1.6 SQLite 3 (nosync) 1.2 0.8 0.4 0 Test 11 Test 12 Test 13 Test 14
  • 39. Benchmarks - Summary • SQLite 3 is faster in almost every test • Using MyISAM would show faster results • Doesn’t test concurrency
  • 40. Converting from MySQL • varchar, char -> text • smallint, tinyint, int -> integer • auto_increment -> autoincrement • unknown types converted to text • MySQLi functions have SQLite3 equivalents
  • 41. Unsupported SQL - Examples Original Image by Clive Arundell
  • 42. Limitations • Very large datasets • High concurrency • No Foreign Keys • Nested Transactions • Writing to Views
  • 43. Miscellaneous • Integrity Check • Reclaim Unused Space • Backup
  • 44. Tools - SQLite Manager
  • 45. Resources • http://www.sqlite.org • http://www.php.net/sqlite3 • http://pecl.php.net/sqlite3 • http://talks.macvicar.net • https://addons.mozilla.org/en-US/firefox/ addon/5817