Displaying 20 results from an estimated 3000 matches similar to: "ActiveRecord searching in batch (with find_by_sql)"
2006 Jul 05
10
Scalable alternative to #find_all
Is there any scalable alternative to iterating all the records of a
certain model? #find_all seems to load everything into memory. With
500.000 records it will be a swap storm.
Pedro.
2020 Nov 13
2
dovecot fts-solr + solr 8.7.0 upgrade: "Indexing failed: 401 Unauthorized" + "Transaction commit failed: FTS transaction commit failed: backend deinit" ?
On 13/11/2020 21:32, PGNet Dev wrote:
> On 11/13/20 11:37 AM, John Fawcett wrote:
>>> still dunno why the 401. :-/
>>
>> So I just did a quick check of running dovecot with a standalone
>> solr-8.7.0 instance and I'm not seeing any issues.
>
> +1
>
>> I confirm I haven't configured anything for indexer or indexer-worker in
>> dovecot, just
2008 Nov 05
3
Rails 2.1.2, complex find involving complex include, bug?
So I''m upgrading my app from Rails 1.2.6 to Rails 2.1.2.
I have a complex find statement that worked in 1.2.6 and isn''t working
in 2.1.2. I think maybe this is a bug, although maybe there''s something
else I could be doing to work-around it?
My find statement involves:
* Models in a module for namespace purposes
* a join clause with raw SQL
* an includes clause with
2005 Oct 28
4
find_by_sql column types
Hello--
There must be a better way to do this. I have a class method in my model
that finds averages and does a few calculations using find_by_sql. The
problem I¹m encountering is that all computed columns from MySQL come back
as type string. E.g.,
def self.find_averages(domain_id)
if @@domain_average
return @@domain_average
else
@@domain_average =
2009 Sep 16
3
find_by_sql - multiple selects, same statement SQL error
I''m trying to get the following statement to work using variable
substitution (it works if hard-code the where (med_type) param in the
inner SQL statement):
med_type = ''game''
@mediaformats = MediaFormat.find_by_sql("select * from media_formats
where media_formats.media_type_id = (select media_type_id from
media_types where media_type = ?, :med_type) order by
2007 Jan 20
2
find_by_sql with named parameterized sql
I tried to use named parameters in my SQL query , using find_by_sql
Order.find_by_sql ([select * from orders where amount > ? and quantity >
?", [ @amount, @quantity ] works;..
but
Order.find_by_sql ([select * from orders where amount > :amount and
quantity > :quantity ", [ :amount => @amt, :quantity => @qty ] is not
working
a I wrong or should I use a plain select
2006 Oct 02
2
when to use find_by_sql
I have a bunch of queries to compute some counters, like
find_by_sql(<<-SQL
SELECT p.*, c.nfavourites
FROM people p, (
SELECT fp.person_id, COUNT(fp.user_id) as nfavourites
FROM favourite_people fp, users u
WHERE fp.user_id = u.id
AND u.cluster = ''#{in_cluster_of_user.cluster}''
GROUP BY fp.person_id
) as c
WHERE
2006 Jan 07
8
Using find_by_sql to get the sum of a column
Hello,
I was wondering if there was a method in Rails that returns the sum of a
column. For example, I have a column called ''score'' and writing a SQL
statement such a ''select sum(score) from table_name'' does return the sum
of the values in the column. In the past (not too long ago being a
newbie), I defined all sorts of methods only to discover that Rails
2006 Apr 18
3
Join Queries? - find() or find_by_sql()
Hi All,
Is there a way to do join queries with find() or is it best to use
find_by_sql() instead?
I''m looking to do something like:
SELECT winery_name, wine_name FROM winery, wine
WHERE wine.winery_id = winery.winery_id
AND winery.winery_name LIKE ''Borg%'';
Thanks!
: )
Jason
2010 May 07
1
undefined method 'find_by_sql'
Why would I get an undefined method `find_by_sql'' for #Example:
0x981a4e4> for error when trying to use the find_by_sql method in my
model?
def init_dictionaries
tables = find_by_sql( "SHOW TABLES FROM thesaurus" )
@@tables = tables.collect{ |t| t.Tables_in_thesaurus }
end
--
You received this message because you are subscribed to the Google Groups "Ruby
2020 Nov 13
1
dovecot fts-solr + solr 8.7.0 upgrade: "Indexing failed: 401 Unauthorized" + "Transaction commit failed: FTS transaction commit failed: backend deinit" ?
On 13/11/2020 22:04, PGNet Dev wrote:
>> I guess you didn't need to enclose username and password in quotes, i.e.
>>
>> fts_solr =
>> url=https://myuser:my%40pass at solr.example.com:8984/solr/dovecot/
>> use_libfts soft_commit=yes batch_size=250
>
> On 11/13/20 12:56 PM, John Fawcett wrote:
>
>> I guess you didn't need to enclose username and
2012 Jun 30
4
find_by_sql and join
hi
I amd tanizawa.
I had problem.
I can not get main.name value from below sql.
"find_by_sql ''select main.id,main.name,sub.name from main left join sub
on sub.id = main.id''"
Please teach me how to get borth name value.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the
2006 Jan 26
1
Help constructing a find_by_sql command
Hello all. I am trying to do the equivalent of:
@componentlogs = Componentlog.find(:all,
:conditions => [ "cl_compname like ?", @criteria ],
:offset => offset,
:limit => items_per_page,
:order => "cl_spr DESC" )
in a find_by_sql statement. I cannot use the build in because the
adaptor isn''t quite right (OCI8)
When I use it I get the following error
2006 Jan 30
1
find_by_sql and memcached
Is a find_by_sql query cached with memcached and cached_model
(http://dev.robotcoop.com/Libraries/)? Looks like the answer is no. Is
there a reason for this? I have a lot of very complicated querys with a
lot of unions, subquerys and joins that would greatly benefit from the
cache.
Going through the code I can see that the find_by_sql method is changed
in cached_model.rb, but it does not call
2007 Aug 14
1
find_by_sql vs connection.select_all
I was trying to do SUM based mySQL query simliar to the following:
SELECT SUM(updated_on - created_on) AS total from signups
If I were to run this command in the mySQL console I would get a
result. However, if I were to run it using the following command in
Rails:
Signup.find_by_sql("SELECT SUM(updated_on - created_on) AS total from
signups")
The query that is written to the log is:
2008 May 30
9
find_by_sql without a model? how to do this?
Hi,
I''d like to do a "find_by_sql" without a model (e.g. <model
name>.find_by_sql("...")) as the results I get back are a once off special,
and I''m happy to handle them as an array. How do I do this?
"ActiveRecord::Base.find_by_sql(...)" does not seem to work?
Background - At the moment I''m doing within a model <model_name>,
2006 Jun 23
7
find_by_sql, can''t print results
I am a little stuck with getting an sql result into my page. I want to
run a select distinct that returns all of the different sections
available and displays this as a form select. In my controller I have:
def edit
@resource = Resource.find(params[:id])
@sections = Resource.find_by_sql "SELECT DISTINCT
resources.section FROM resources"
end
And then in my view I have:
<%
2011 Dec 07
5
Find_by_sql help?
How to make it work with paginator (kaminari)?
MySQL and full text search: Words (id, word)
@words = Word.find_by_sql(["SELECT id, word, MATCH (word) AGAINST (?) AS
Score FROM words WHERE MATCH (word) AGAINST (?) ORDER BY Score Desc,
word!=?", params[:search],params[:search],params[:search]])
I can''t add .page(params[:page]).per(5) to the end of "find_by_sql()" so
2005 Dec 21
7
use of SET command in find_by_sql
Hi,
I''m trying to execute something like this method in a model:
def self.sql_for_rankings()
sql = "SET @counter:=0;"
sql << " SET @counter:=0;
SELECT *, @counter:=@counter+1 AS rank
FROM testscores. "
find_by_sql(sql)
end
Where the new rank column is a kind of autoincrementer inside of
2008 Jun 26
9
find_by_sql + Join + Rails 2
Hello
I have write a code to select data from two tables (T1,T2) but the
problem is
@tables= T1.find_by_sql("select T1.*,T2.* from T1inner join T2on
T1.followup_id = T2.id where followups.userid = ''41'' ")
THe problem all values that is returned from running only T1
variables,why?
Where are T2 variables??
--
Posted via http://www.ruby-forum.com/.