0

I have a SQL table Student. It has 30 columns (properties) for each student.

I need 10 properties in a SQL query.

Which one is better approach ?

  1. q1 = 'SELECT * FROM STUDENTS where uid in %s'%tuple(list1);

  2. for k in properties:

     `q1 = 'SELECT k FROM STUDENTS where uid in %s'%tuple(list1);`
    

Mainly comparison is between single I/O with huge amount of data or multiple I/O with less amount of data

I think the 1st approach is better as in single IO all data will be loaded to memory then iterating over it is faster in memory

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Prannoy Mittal
  • 1,525
  • 5
  • 21
  • 32
  • If you only need 10 out of 30 fields, why does option 1 select all 30? – Dan Bracuk Nov 05 '15 at 17:31
  • This is one of those cases where the most accurate response will be whatever you determine from trying it yourself, in your own environment, under your conditions. – Andy Lester Nov 05 '15 at 18:40

1 Answers1

0
select k1, k2, k3, k4, k5, k6, k7, k8, k9, k10 from STUDENTS where uid in %s'%tuple(list1);
paparazzo
  • 44,497
  • 23
  • 105
  • 176