SELECT distinct(partition) FROM system.parts WHERE table = 'events' <%= if @start_from do %>AND partition >= '<%= @start_from %>'<% end %> <%= if @stop_at do %>AND partition <= '<%= @stop_at %>'<% end %> ORDER BY partition