title: run a set of queries faster with python and postgres
body: <p>in my example, I have a list of 3000 words to search in a database, so with this pyhton code (I am using django) the operation takes a lot of time and is done in 3.5 minutes with the average of 120ms for a querie.  is there a method to speed up the execution of these queries with a script python using threads or something like that?</p>
  <pre><code> def my_custom_sql(ent):
      for e in ent:
          with connection.cursor() as cursor:
              entity=e.replace(&quot;'&quot;,&quot;''&quot;)
           
              cursor.execute(&quot;SELECT object FROM yagofacts WHERE subject='{}' AND object LIKE '&lt;wordnet_%&gt;';&quot;.format(entity))
           
              row = cursor.fetchall()
              print(row)
                 
  </code></pre>