kylemaxxwell / rpostgresql

Automatically exported from code.google.com/p/rpostgresql
0 stars 0 forks source link

why is it much faster running sql under PostgreSQL than running sql using RPostgreSQL package? #64

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What I did is on the website 
http://stackoverflow.com/questions/25177642/how-to-select-efficiently-in-a-very-
large-table

I used RPostgreSQL package under R because I want to manipulate other files at 
the same time. As you can see from the above website, the table is very large. 
It will cost more than two hours to complete the selection using RPostgreSQL. 
But today I use the same SQL code under PostgreSQL directly instead of using 
RpostgreSQL. It only took several minutes. Why?

The code of R is:

sql='SELECT * into new_table FROM table_1 WHERE EXISTS (SELECT 1 FROM table_2 
WHERE column=table_1.column_1) AND EXISTS (SELECT 1 FROM table_2 WHERE 
column=table_1.column_2)'
rs=dbSendQuery(con,sql)

Original issue reported on code.google.com by guanghua...@gmail.com on 28 Aug 2014 at 9:49