Forum: Ruby on Rails query performance boost

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ukrit H. (Guest)
on 2009-01-16 06:09
I've a table with structure like this:

id: int
field1: varchar(255)
field2: int(11)
field3: text
field4: text
field5: varchar(255)
field6: varchar(255)

assume that this table contains massive contents on field 3 and 4
So any way that I will be able to access this table quicker than my
current query?


And this is the way I'm access this table:

Table.find(:all, :include=> "relate_table")

please give me some hint (and I need all fields to display on page)
Ukrit H. (Guest)
on 2009-01-16 10:47
Ukrit H. wrote:
> I've a table with structure like this:
>
> id: int
> field1: varchar(255)
> field2: int(11)
> field3: text
> field4: text
> field5: varchar(255)
> field6: varchar(255)
>
> assume that this table contains massive contents on field 3 and 4
> So any way that I will be able to access this table quicker than my
> current query?
>
>
> And this is the way I'm access this table:
>
> Table.find(:all, :include=> "relate_table")
>
> please give me some hint (and I need all fields to display on page)



would anyone mind giving some idea?
Shiv N Gautam (Guest)
on 2009-01-16 11:08
(Received via mailing list)
Assuming you're using MySQL these might help you.

http://dev.mysql.com/doc/refman/5.1/en/static-format.html
http://dev.mysql.com/doc/refman/5.1/en/dynamic-format.html

--
Shiv N Gautam

On Fri, Jan 16, 2009 at 2:17 PM, Ukrit H. <
removed_email_address@domain.invalid> wrote:

> > field6: varchar(255)
> > please give me some hint (and I need all fields to display on page)
>
>
>
> would anyone mind giving some idea?
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--

Robert Orben  - "To err is human - and to blame it on a computer is even
more so."
Jeffrey L. Taylor (Guest)
on 2009-01-17 06:22
(Received via mailing list)
Quoting Ukrit H. <removed_email_address@domain.invalid>:
>
> assume that this table contains massive contents on field 3 and 4
> So any way that I will be able to access this table quicker than my
> current query?
>
>
> And this is the way I'm access this table:
>
> Table.find(:all, :include=> "relate_table")
>
Table.connection.select_row("SELECT * FROM table, relate_table
WHERE table.relate_table_id = relate_table.id")

Returns an array of strings.  This is from memory.  The function name
may not be quite correct.

HTH,
  Jeffrey
Robby R. (Guest)
on 2009-01-18 21:41
(Received via mailing list)
On Thu, Jan 15, 2009 at 8:09 PM, Ukrit H.
<removed_email_address@domain.invalid> wrote:
>
> assume that this table contains massive contents on field 3 and 4
> So any way that I will be able to access this table quicker than my
> current query?
>
>
> And this is the way I'm access this table:
>
> Table.find(:all, :include=> "relate_table")
>
> please give me some hint (and I need all fields to display on page)


You can use :select in your calls to find to select specific fields to
retrieve data for.  Here is a quick writeup on it.

* http://www.geekskillz.com/articles/11

Good luck!

Cheers,
Robby


--
Robby R.
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting w/Ruby on Rails

http://www.planetargon.com/
http://www.robbyonrails.com/
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]
This topic is locked and can not be replied to.