SELECT specific columns? #60

Closed
johnrees opened this Issue Sep 17, 2012 · 8 comments

Projects

None yet

6 participants

@johnrees
# Foo.rb
pg_search_scope :search, against: :name

# Query
Foo.select('id,name').search('bar')
# or
Foo.select('foos.id,foos.name').search('bar')
# or
Foo.search('bar').select('id,name')

# Yields
SELECT id,name, "foos".*...

is there a way of avoiding this behaviour and just loading the fields specified without the added select-all directive? As I want to utilise PG9.2's index-only scans if possible.

@dreamingfurther

Had we not written a patch for this issue when I worked on this for a day with you Grant while I was a candidate? Or are you trying to solve it in a better way than what we wrote up that afternoon?

@nertzy
Collaborator
nertzy commented Dec 14, 2012

Yes, we did work on a fix. I want to merge it in but haven't yet due to some weird and complex edge cases. (See #79 for an example of one of them)

https://github.com/Casecommons/pg_search/tree/fix-chaining-with-select is the code we worked on.

I will work on getting some of these issues out into the open and discussing them here on GitHub.

@dreamingfurther

Yea I'll take a look at the example posted in #79 and if you have other examples you can post to GitHub I'll look at those as well. If I can find a solution that satisfies these edge cases I'll submit a pull request.

I should be joining the Pivotal team in January so why not get in on the fun early? :-)

This was referenced Jan 25, 2013
@eddietejeda

I would love to see this get merged in. Any plans?

@alexpatriquin

Upvote on the merge.

@ajb
Collaborator
ajb commented Dec 2, 2014

This has been over 2 years, which is getting pretty insane. We're currently working around this issue, but it's causing up to a 2 second performance hit in extreme cases. (!!)

I'm going to see what can be done, but @nertzy, any help from you would be much appreciated.

@nertzy
Collaborator
nertzy commented Feb 22, 2015

Fixed by eb730f7 which has just been added to master.

Test added in a074acb.

@nertzy nertzy closed this Feb 22, 2015
@ajb
Collaborator
ajb commented Feb 23, 2015

Will test this out in our application shortly. Thanks Grant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment