• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
SQLite 3
 

SQLite 3

on

  • 17,751 views

Talk on SQLite given at PHP Barcelona 2008

Talk on SQLite given at PHP Barcelona 2008

Statistics

Views

Total Views
17,751
Views on SlideShare
17,391
Embed Views
360

Actions

Likes
13
Downloads
0
Comments
0

7 Embeds 360

http://phpconference.es 151
http://phpbarcelona.org 122
http://www.slideshare.net 67
http://shadwell 15
http://adnam.motd.org 3
http://static.slidesharecdn.com 1
http://www.search-results.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    SQLite 3 SQLite 3 Presentation Transcript

    • 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