Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Impossible to configure the column to use for the Distinct close #202

Open
eltados opened this Issue Nov 17, 2011 · 0 comments

Comments

Projects
None yet
1 participant

eltados commented Nov 17, 2011

I have a model Page with a number of column one of which is a column containing very big entry

Therefore i want to specify the select clause in order to exclude this column ( for obvious performance reason )

   pages.order("created_at desc").paginate(:page => params[:page], :per_page => 7).select("`pages`.`id`, `pages`.`url`, `pages`.`title`, `pages`.`author`, `pages`.`date`, `pages`.`text`,  `pages`.`media`, `pages`.`type`, `pages`.`image_url`, `pages`.`image_height`, `pages`.`image_width`, `pages`.`created_at`, `pages`.`updated_at`, `pages`.`image_file_name`, `pages`.`image_content_type`, `pages`.`image_file_size`, `pages`.`image_updated_at`, `pages`.`debug`, `pages`.`published_at`")

Generates

  SELECT DISTINCT `pages`.*, `pages`.`id`, `pages`.`url`, `pages`.`title`, `pages`.`author`, `pages`.`date`, `pages`.`text`,  `pages`.`media`, `pages`.`type`, `pages`.`image_url`, `pages`.`image_height`, `pages`.`image_width`, `pages`.`created_at`, `pages`.`updated_at`, `pages`.`image_file_name`, `pages`.`image_content_type`, `pages`.`image_file_size`, `pages`.`image_updated_at`, `pages`.`debug`, `pages`.`published_at` FROM `pages`  ORDER BY created_at desc LIMIT 7 OFFSET 28

The problem is that will_paginate generate DISTINCT pages.* which load all. Is there a way to specify the column to use for the DISCTINCT ? I could not find anything on the Net or reading the source code.

I know that this problem can be solved by extracting out this large column out of the table but this out of the possibility now because many ( good and bad ) internal reasons.

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