Git Product home page Git Product logo

chooseme's Introduction

Chooseme. Index chooser for your rails powered application

Sometimes database do what you expect, sometimes not. If you have small application with small piece of data in your database, you will not have so much problems if your MySQL (or any other db) choose not relevant index.

But sometimes you handle really big database and database mistake may cost you money and nervous. It's not good idea to hard-writing indexes in your sql queries, but what you say if index will be selected by automated method?

How it works now

First of all, behind the scene, Chooseme fetch all indexes from your db/schema.rb file.

###Example query to Chooseme:

 Chooseme::Chooser.choose!(SomeModel, [:list,:of,:used,:columns]) #-> ix_with_list_of_used_columns_if_possible_or_nil

Yes, at this time there are not much magic and you must pass used columns. By the way, in complex queries with bunch of joins it's the only way. Maybe, some time later, magic will be here, but now... :)

###Example of real usage

used_columns=[:name, :founded_at]
ix=Chooseme::Chooser.choose!(City, used_columns)
cities=City.where(:name=>"Moscow", :founded_at=>1147)
cities=cities.from("#{City.table_name} USE INDEX (#{ix})") unless ix.nil?

Installation?

Well, i think you know without my explanation, but...

gem 'chooseme', :git=>'git://github.com/rap-kasta/chooseme.git'  #add this line to your Gemfile

TODO

  • Tests

  • Docs

  • Magic

Author

Pavel Manylov aka [r-k] / rap_kasta on github

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.