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

How To be a Backend developer
How To be a Backend developer    How To be a Backend developer
How To be a Backend developer Ramy Hakam
 
Flyway _ A Database Version Management Tool
Flyway _ A Database Version Management ToolFlyway _ A Database Version Management Tool
Flyway _ A Database Version Management ToolKnoldus Inc.
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP TutorialLorna Mitchell
 
PyCon Korea 2019 REST API Document Generation
PyCon Korea 2019 REST API Document GenerationPyCon Korea 2019 REST API Document Generation
PyCon Korea 2019 REST API Document Generation용선 이
 
Web Services
Web ServicesWeb Services
Web Serviceschidi
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 
Building microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring BootBuilding microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring BootChris Richardson
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipIvan Paulovich
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
SQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesSQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesOsama Jomaa
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesVijay Rangaiah
 
ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1Kumar S
 
Introdução ao Front-end no Desenvolvimento Web
Introdução ao Front-end no Desenvolvimento WebIntrodução ao Front-end no Desenvolvimento Web
Introdução ao Front-end no Desenvolvimento WebAnderson Luís Furlan
 
NOSQL uma breve introdução
NOSQL uma breve introduçãoNOSQL uma breve introdução
NOSQL uma breve introduçãoWise Systems
 

Mais procurados (20)

How To be a Backend developer
How To be a Backend developer    How To be a Backend developer
How To be a Backend developer
 
Flyway _ A Database Version Management Tool
Flyway _ A Database Version Management ToolFlyway _ A Database Version Management Tool
Flyway _ A Database Version Management Tool
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
PyCon Korea 2019 REST API Document Generation
PyCon Korea 2019 REST API Document GenerationPyCon Korea 2019 REST API Document Generation
PyCon Korea 2019 REST API Document Generation
 
Rest API
Rest APIRest API
Rest API
 
Web Services
Web ServicesWeb Services
Web Services
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
React js
React jsReact js
React js
 
Building microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring BootBuilding microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring Boot
 
AngularJS
AngularJS AngularJS
AngularJS
 
Clean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software CraftsmanshipClean Architecture Essentials - Stockholm Software Craftsmanship
Clean Architecture Essentials - Stockholm Software Craftsmanship
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
SQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesSQL vs. NoSQL Databases
SQL vs. NoSQL Databases
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering Colleges
 
ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1
 
Selenium
SeleniumSelenium
Selenium
 
SQL & NoSQL
SQL & NoSQLSQL & NoSQL
SQL & NoSQL
 
Introdução ao Front-end no Desenvolvimento Web
Introdução ao Front-end no Desenvolvimento WebIntrodução ao Front-end no Desenvolvimento Web
Introdução ao Front-end no Desenvolvimento Web
 
NOSQL uma breve introdução
NOSQL uma breve introduçãoNOSQL uma breve introdução
NOSQL uma breve introdução
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 

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
 
SQLite3
SQLite3SQLite3
SQLite3cltru
 
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
 
Sqlite
SqliteSqlite
Sqlite
 
Introduction4 SQLite
Introduction4 SQLiteIntroduction4 SQLite
Introduction4 SQLite
 
SQLite3
SQLite3SQLite3
SQLite3
 
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 소개와 구조 분석
 
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
 

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

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Último (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 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