The idea behind :select is that you supply a SQL string which represents the attributes of the objects you want to fetch (or columns in the row if you're me and old school). Let's say that you want to get only the id of the object, the created_at and the updated_at in a table called apps then your :select would look like this: :select => " apps.id, " + "apps.created_at, " + "apps.updated_at "
And that will be injected into your query by ActiveRecord…
October 28-30 | Atlanta, GA
We haven't been to Atlanta in a while, so we're excited about no:sql(east)! Engine Yard will be represented by our very own John Hornbeck, who will be talking about MongoDB ( Key-Value Stores are really all the rage these days! Check out our recent series of posts on the topic, including MongoDB).
October 30-31 | Amsterdam
This will be our first time in Amsterdam, and we're …
I recently had to deal with performance problems in a very large application with a considerable number of SQL queries (i.e. object.find_by_sql or object.paginate_by_sql). And while we can argue whether or not using sql directly in an ActiveRecord context is good, some of these were complex enough (think sum operations, etc) that I didn't want to go and rewrite them as ActiveRecord. And, given a table that is being changed constantly by a crawler, the MySQL query cache wasn't an option*.
The NoSQL movement faults the SQL query language as the source of many of the scalability issues that we face today with traditional database approach.
I think that the main reason so many people have come to see SQL as the source of all evil is the fact that, traditionally, the query language was burned into the database implementation. So by saying NoSQL you basically say "No" to the traditional non-scalable RDBMS implementations.
This view has brought on a flood …
The database is being backed up nightly via a SQL dump, which is then backed up on a tape. Additionally, just before an upgrade, we take a ZFS snapshot of the filesystem the db files reside on. This allows us to do instant rollbacks in case the upgrade fails. I experienced a situation where it took us hours to roll back from a SQL dump. It's slooow. Since then we switched to ZFS snapshots.
The database is really the master storage of all the Confluence data, so in addition to all …
Title says it all really. I finally got tired of importing the ipinfodb into postgreSQL via CSV (the SQL they provide on their site targets MySQL), and have made a dump available on S3. Knock yourself out.
http://stokumine.s3.amazonaws.com/ipinfodb_one_table_small_pgsql.sql.gz
The SQL standard specifies levels for how "isolated" transactions running at the same time are, all the way from being able to see uncommitted changes (not isolated) to effectively running the transactions in serial (full isolation). Academically there are eight levels of isolation, but for most purposes you only need to worry about the four defined by the standard. MySQL implements all four, PostgreSQL only two. You can specify a global isolation level for your database, but also …
SQL:
# 475s user time, 1.2s system time, 80.41M rss, 170.38M vsz
# Current date: Mon Jul 19 15:12:24 2010
# Files: slow-log
# Overall: 1.22M total, 1.27k unique, 558.56 QPS, 0.37x concurrency ______
# total min max avg 95% stddev median
# Exec time 819s 1us 92s 669us 260us 120ms 93us
# Lock time 28s 0 166ms 23us 49us 192us 25us
# Rows sent 4.27k 0 325 0.00 0 1.04 0
# Rows exam 30.88M 0 1.28M 26.48 0 3.07k 0
# Time range 2010-07-19 14:35:53 to 2010-07-19 …
…through the above example again, the first process to execute the find will issue the following SQL: SELECT * FROM purchase_orders WHERE id = 1 FOR UPDATE Notice the "FOR UPDATE" on the end; this instructs the database to place an exclusive lock on the row. When the second process executes the find and submits the above SQL to the database, the database will wait for the first transaction to complete (after calling ship! and updating the state of the order) before reading and returning …
Why NoSQL Matters
" NoSQL" is a label which encompasses a wave of innovation now happening in the database space. The NoSQL movement has sparked a whirlwind of discussion, debate, and excitement in the technical community. Why is NoSQL generating so much buzz? What does it mean for you, the application developer? And what place does NoSQL have for apps running on the Heroku platform?
SQL (the language) and SQL RDBMS implementations ( MySQL, PostgreSQL, Oracle…