Code Monkey home page Code Monkey logo

knowsql's Introduction

KnowSQL

Compound Index slide was the 5 minute mark.

Goal

  1. you don't know what you don't know
  2. awareness > complete comprehension
  3. open the fire hydant: you don't have to drink it all, but I will soak you
  4. Easier

Chapter 1: Indexing

  • Basic index (bench - show seq vs idx)
  • unique index (faster than rails - bench)
  • index on expressions (w/ unique)
    • mathematical operators and functions
    • email verification regex
  • compound (multi-type indexing - Gist & GIN)
  • foreign keys
    • polymorphic foreign keys

Chapter 2: Foreign Keys

  • What is an FK in a relational db
  • dangers of invalid associations
    1. You create parent A
    2. You create child X under A
    3. Someone deletes A while you create X
    4. You go to the child page and it 500s because it can't load the parent
  • If there is no way to get to the content in your site you can orphan a lot of data
    • What if that data was videos or images?
  • Rails validations are really inefficient
    • bad: validates_presence_of :child ( has to load the child )
    • good: fk on child_id + validates_presence_of :child_id
  • Sometimes people call "Model.delete" or save(:validations => false)
  • Sometimes people load up the DB console
  • Rails validations are redundant
  • Put the validation where it matters and use rails for pretty error messages
  • Show the foreigner gem

Chapter 3: Fancy Queries

  • Joins w/ :include and :select for single query access
  • complex aggregation (partition)
  • nested queries (Subquery)
  • pattern matching (LIKE and also regex)
  • views (like for search, or for a twitter timeline)

Chapter 4: Full Text Search

Chapter 5: Geospatial

  • Setup PostGIS (w/ ubuntu repo)
  • Easy migration to add a point to something
  • Geospatial index
  • Compound index w/ geospatial
  • Searching within polygons, radii, etc
  • Fast (twitter? earthquakes?)
  • Fast (bench vs mongo geospatial? http://www.mongodb.org/display/DOCS/Geospatial+Indexing )

Chapter 6: Shoulders of Giants

knowsql's People

Contributors

ngauthier avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.