similar to: Custom Mysql queries slower than ActiveRecord in production

Displaying 20 results from an estimated 50000 matches similar to: "Custom Mysql queries slower than ActiveRecord in production"

2004 Dec 15
4
AR db adapter for a RDF database (ATT: DHH)
Hi people, As I stated in a earlier message, I am using Rails on my masters degree and soon I will have to port my application from a relational database (MySql) to a RDF semantic database called Sesame. At first, I thought that I could get away with most of the porting only by writing a decent database adapter, but then, examining AR closer, I could see that it has some strong dependencies
2000 Aug 24
0
patch for a few things
This isn't related to the snapshot, but mention of it reminded me to submit these changes. I added a few things, and made a couple small changes; here's a list of what the patch includes: - adds a "-1" argument to ssh and ssh.1 to force protocol1, similar to the existing "-2" argument. - adds "-1" and "-2" to scp and scp.1 as well. - adds
2010 Aug 16
2
Form validation and processing w/o model (no Db/ActiveRecord)
All - Trying not to fight rails on this, basically have a form and all the same as would be with an ActiveRecord model except that there is no table. I started out using this article: http://stackoverflow.com/questions/315850/rails-model-without-database ...which is kind of a hack by inheriting ActiveRecord in to non-AR model but am running into some problems and just have the feeling that I am
2006 Jul 31
1
Pagination of Complex Queries
I''ve created a class method in my model called find_filtered. The intent is that I take various params that the user has submitted, and let the model build the query and return the AR collection, which is exactly what happens. However, now I''d like to paginate the recordset. Everything I''ve been able to find about pagination presumes that you have no pre-existing AR
2009 Mar 07
0
Be careful of BIGINT primary key fields in MySQL. Will cause problems with ActiveRecord create (but not find)
The MySQL/Ruby library doesn''t properly handle inserts into tables with the primary key being a BIGINT If the ID returned to the MySQL/Ruby library is LARGER than the INT range, the value is returned to Ruby truncated and incorrect. This is then passed up to ActiveRecord and into the id field of your model. The actual INSERT worked properly and when do you an ActiveRecord find for the
2008 Apr 24
0
ActiveRecord - INSERT options for MySQL
Hi, Excuse any mistakes I make in advance- this is my first post to the RoR list, and it''s going right in at the deep end... I''ve been working with Rails for quite a bit now (8ish months or so) and I''ve worked on two projects where there are several points in which access to INSERT statement options would be extremely useful. I''m using MySQL, where there is
2006 Mar 27
5
Fake ActiveRecord model?
Hi all, I have a legacy table which I cannot get to work with ActiveRecord (no ids etc). All I want is to create a class which opens a connection manually and allows me to execute some plain SQL statements. What I can''t figure out is how to either build up a connection and execute queries from a non-AR inherited class, or how to create a AR-inherited class minus all the AR magic and
2006 Aug 13
2
Arbitrary "Columns" for ActiveRecord
I''m having a bit of a tough time coming up with a good solution for what I''m trying to do. I''ve come up with a couple of solutions that work pretty well but many use way too many queries or are just not very good. Basically I want to store something of a property list for a model. class Model < AR has_many :properties, :dependent => :delete end class
2007 Apr 04
1
[PLUGIN] count_from_query - easily convert finder queries into count queries
count_from_query gives you the ability to generate a COUNT query from a standard Rails find. For example, if you have the query User.find :all it would be trivial to get a count: User.count however, if you have a more specific finder method, such as class Company < ActiveRecord::Base def complete_videos Video.find :all, :conditions => "company_id=#{id} AND
2006 Jul 22
2
How to SELECT from multiple talbes with AR#find and associations?
So I want to SELECT from multiple tables, so as to be able to do "SELECT FROM foo, bar WHERE foo.id=bar.id AND bar.baz=23". How do I do it with AR#find? Also, I need this for associations. has_many et. al. have :finder_sql, which is nice, but feels like a Pyrrhic: it''s basically doing the association in pure SQL, defeating the purpose of AR. -- -Alder
2006 Apr 04
1
ActiveRecord object
I have an ActiveRecord class class User < ActiveRecord::Base end and I want to define an attribute, in example "links", links will be an array. class User < ActiveRecord::Base attr :links end and now, I want links to be an array, so I do class User < ActiveRecord::base attr:links def initialize(attributes) super(attributes) @links =
2006 Jul 21
2
File.open behavior for ActiveRecord, to ensure save after manipulation?
File.open in core Ruby is nifty, in that it automagically closes the file when you''re done using/manipulating it. I''m wondering whether there''s something like that for ActiveRecord? So you can do: AR.find(23).open {|ar| ar.foo = ''bar'' ... } And ar.save would be called when the block closes. -- -Alder
2012 Jan 11
4
ActiveRecord: ar-each_model
Hi, today I went into a problem, when I had to iterate over a big result set. ActiveRecord produces a huge array of model instances, which consumed 1GB of memory on my machine. A comparable perl DBI script only used some KB for iterating over the result set. Then I was suggested to use batch (#find_each) for the problem. But basically batch does the same thing by splitting the query into several
2009 Dec 29
2
Realtime mysql extensions mutiple queries for each priority?
Hi All, I'm testing some realtime extension apps with Asterisk 1.4.28 and addons 1.4.10 using res_mysql. Localhost database is 5.0.32 with Debian Etch. The apps are working fine all syntax is proper, using Set with (REALTIME) function, Set with (CUT) function, calling a Macro with s extensions, and using a few pattern matching extensions as well. I can certainly detail all database rows if
2012 Nov 13
4
Proper use of the where method om ActiveRecord.
I am trying to determine what is going on with the following code: In AR def self.all_billables where( :is_billed => false ) end returns 2 records. def self.all_billables where( "is_billed" => false ) end also returns 2 records. In sqlite3 sqlite> select * from tests where ( "is_billed" = ''false'' ); returns 2 records. However, if I use
2006 Jun 20
4
Searching ActiveRecord sets
Hey all, I''m learning AR and I''m trying to find the best way to search an ActiveRecord set in order to make a conditional statement decision, something like .has_value?(value) but for a multi-dimensional array like an AR set of like 100 rows. I know I can do something like this: results = Table.find_by_sql("...") for result in results if
2006 Aug 17
0
Using Views in ActiveRecord ?
Hello all, I have an enterprise MS SQL Server database system that is being used by multiple applications, both web and windows-clients. Some of the "tables" used by many databases are stored in one accessible database and used as views in the local database of each application. I understand that I can setup multiple database AR connections. That is a potential alternative. I want to
2006 Jun 23
0
help... can''t run ActiveRecord unit tests to test bug fix
I found a bug in ActiveRecord. Being a good netizen, I thought I would write a test to illustrate the bug, fix it, and then submit a patch to the maintainers. However, I can''t run the AR tests. I followed the instructions in RUNNING_UNIT_TESTS but it generates an error immediately /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/test cremes$ ruby -I
2006 Jul 16
1
form helpers with non-ActiveRecord objects
I have an ActiveRecord model (called Festival) that contains an array of "FestDate" objects serialized into a sql text column of the Festival object. (like the Agile book first edition describes on p. 205) The FestDate objects themselvs are not ActiveRecord objects. (of course, otherwise they would be in their own table...) When working with a Festival, I would like to use various
2006 Jun 18
1
Put an arbitary hash into ActiveRecord
Did someone encountered a problem of putting a hash of values into AR, into a certain field? Essentially I need some denormalized, freeform serializable hash to which the user can add keys and values, and handle accessors from there would be lovely too. I remember that AR has "serialize" but did someone actually use it? I heard nothing but complaints about rich objects in AR