title: how to run a big query without imposing too much load on the server
body: <p>I have a query which takes 10 minutes to return data, and it puts a big load on our server. How can run this query without imposing such a big load on the server?</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT m_time_stamp,
         m_wind_speed,
         m_wind_dir,
         m_power,
         m_lim_free_time,
         m_turb_int,
         m_wind_speed_norm,
         m_ntf_wind_speed,
         m_st_run,
         m_availability
  FROM t_statistics_10_m
  where m_time_stamp&gt;='2014-10-01' and m_turbine_id='xxx.xxx.xx.xx'
  </code></pre>
  <p>here is the execution plan</p>
  <pre class="lang-none prettyprint-override"><code>Append  (cost=0.00..3175487.56 rows=283409 width=44) (actual time=108.108..127531.966 rows=297644 loops=1)
    Buffers: shared hit=347556 read=319238 written=4
    -&gt;  Seq Scan on t_statistics_10_m  (cost=0.00..1.01 rows=1 width=44) (actual time=0.003..0.003 rows=0 loops=1)
          Filter: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Rows Removed by Filter: 1
          Buffers: shared hit=1
    -&gt;  Bitmap Heap Scan on t_statistics_10_m_2014  (cost=87490.62..131541.09 rows=12100 width=44) (actual time=108.103..112.539 rows=4039 loops=1)
          Recheck Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Heap Blocks: exact=1957
          Buffers: shared hit=14873
          -&gt;  Bitmap Index Scan on t_statistics_10_m_2014_pkey  (cost=0.00..87487.60 rows=12100 width=0) (actual time=106.924..107.924 rows=4039 loops=1)
                Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
                Buffers: shared hit=12916
    -&gt;  Index Scan using t_statistics_10_m_2015_pkey on t_statistics_10_m_2015  (cost=0.56..439353.65 rows=43876 width=44) (actual time=0.02..24624.128 rows=51875 loops=1)
          Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Buffers: shared hit=58116 read=46997
    -&gt;  Bitmap Heap Scan on t_statistics_10_m_2016  (cost=400979.11..553265.63 rows=45818 width=44) (actual time=641.667..28871.488 rows=51745 loops=1)
          Recheck Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Heap Blocks: exact=41625
          Buffers: shared hit=60479 read=41627
          -&gt;  Bitmap Index Scan on t_statistics_10_m_2016_pkey  (cost=0.00..400967.66 rows=45818 width=0) (actual time=630.035..630.035 rows=51745 loops=1)
                Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
                Buffers: shared hit=60479 read=2
    -&gt;  Index Scan using t_statistics_10_m_2017_pkey on t_statistics_10_m_2017  (cost=0.56..552277.59 rows=46713 width=44) (actual time=0.058..18107.842 rows=52248 loops=1)
          Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Buffers: shared hit=64751 read=44575
    -&gt;  Index Scan using t_statistics_10_m_out_of_range_pkey on t_statistics_10_m_out_of_range  (cost=0.14..8.32 rows=1 width=44) (actual time=0.007..0.007 rows=0 loops=1)
          Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Buffers: shared hit=1
    -&gt;  Index Scan using t_statistics_10_m_2018_pkey on t_statistics_10_m_2018  (cost=0.56..503705.67 rows=44849 width=44) (actual time=0.731..34621.832 rows=52174 loops=1)
          Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Buffers: shared hit=64354 read=51926
    -&gt;  Index Scan using t_statistics_10_m_2019_pkey on t_statistics_10_m_2019  (cost=0.56..615897.33 rows=60219 width=44) (actual time=0.037..11791.200 rows=51481 loops=1)
          Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Buffers: shared hit=29768 read=103121
    -&gt;  Index Scan using t_statistics_10_m_2020_pkey on t_statistics_10_m_2020  (cost=0.43..379437.27 rows=29832 width=44) (actual time=0.866..9356.176 rows=34082 loops=1)
          Index Cond: ((m_time_stamp &gt;= '2014-10-01 00:00:00'::timestamp without time zone) AND (m_turbine_id = 'xx.xx.xx.xx'::inet))
          Buffers: shared hit=55213 read=30992 written=4
  Planning time: 1.322 ms
  Execution time: 127558.480 ms'
  </code></pre>