github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

sdsykes / slim-attributes

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 43
    • 4
  • Source
  • Commits
  • Network (4)
  • Issues (0)
  • Downloads (7)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (7)
    • v0.7.5
    • v0.7.4
    • v0.7.1
    • v0.6.6
    • v0.6.3
    • v0.6.2
    • v0.6.1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Boosts speed in ActiveRecord models with mysql by lazily instantiating attributes as needed. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Doc updates.  Update gemspec. 
sdsykes (author)
Tue Dec 29 12:59:30 -0800 2009
commit  9821861b7220e7a9299cc2fe84fdf0731a91f199
tree    66c53f96fb7afe816d649cc82a624fc3a7f62b9b
parent  6ad009a45256c0e99f7af331573d3c9ebdf12582
slim-attributes /
name age
history
message
file MIT_LICENCE Sun Apr 06 02:09:47 -0700 2008 Initial import [sdsykes]
file README Loading commit data...
file Rakefile Tue Oct 20 22:34:31 -0700 2009 Fix for rdoc task that jeweler requires [sdsykes]
file VERSION.yml Wed Dec 23 11:48:06 -0800 2009 Version bump to 0.7.6 [sdsykes]
directory ext/
directory lib/ Wed Dec 23 06:51:40 -0800 2009 Added slim-attributes.rb so you don't have to s... [fnando]
file slim-attributes.gemspec
directory test/ Mon Sep 07 04:21:23 -0700 2009 Added additional test that slim attributes is w... [sdsykes]
README
SlimAttributes
==============

This is a small patch to the ActiveRecord Mysql adaptor that stops rails from using the all_hashes / each_hash mechanism 
- which is what is called when you do a find.

It is faster, and uses less memory.

Measuring with just ActiveRecord code - fetching stuff from the database - we see anything up to a 50% (or more) speed 
increase, but I suppose it really depends on your system and environment, and what you are doing with the results from 
the database.  The more columns your tables have, the better the improvement will likely be.  Measure your own system 
and send me the results!


Installation
============

Slim attributes works with Rails and Ruby 1.8.x.  Ruby 1.9 is also supported with Rails version 2.3.5 and above.

Try:
  sudo gem install slim-attributes
or:
  sudo gem install slim-attributes -- --with-mysql-config

then add this to environment.rb in the Rails::Initializer.run section:

  config.gem 'slim-attributes'


Description
===========

The reason for overriding all_hashes is threefold:

* making a hash of each and every row returned from the database is slow
* ruby makes frozen copies of each column name string (for the keys) which results in a great many strings which are not 
really needed
* we observe that it's not often that all the fields of rows fetched from the database are actually used

So this is an alternative implementation of all_hashes that returns a 'fake hash' which contains a hash of the column 
names (the same hash of names is used for every row), and also contains the row data in an area memcpy'd directly from 
the mysql API.

The field contents are then instantiated into Ruby strings on demand - ruby strings are only made if you need them.  
Note that if you always look at all the columns when you fetch data from the database then this won't necessarily be 
faster that the unpatched mysql adapter.  But it won't be much slower either, and we do expect that most times not all 
the columns from a result set are accessed.


Bugs
====

Slim attributes will not work correctly with ruby 1.9.x with versions lower than Rails 2.3.5


Warranty
========

No warranty - this gem has been extensively tested, but not in all environments.  
We are using it in our production environment with very good results.
Please report bugs to sdsykes at symbol gmail pip com or via the github issue tracking system.


Credits
=======

Thanks to IronDigital for the initial port for ruby 1.9.
Thanks to Greg Hazel (ghazel) for fixing compilation for windows.
Thanks to Nando Vieira (fnando) for adding slim-attributes.rb to avoid the underscore dash confusion.

Copyright (c) 2008-2010 Stephen Sykes, released under the MIT license
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server