Posts

Showing posts from March, 2012

Who is best with MySQL? R or Perl or Python: A benchmark

I really surprised to see R talks better with MySQL than Perl or Python!!!... I thought R might be slow in querying MySQL database. But I have a different answer here. Following is the code used for this demo. R script: library(RMySQL) test <- function(){          con <- dbConnect("MySQL", host="genome-mysql.cse.ucsc.edu", user ="genome", dbname = "hg18")          rs <- dbGetQuery(con, "select name, chromEnd from snp129 where chrom='chr1' and chromStart between 1 and 1e8;")          return(rs)          dbClearResult(rs)          dbDisconnect(con)         } print(system.time(test()))    user  system elapsed   0.372   0.039  25.729 R took 25.729 seconds to retrieve half million records. Python script: from time import time import MySQLdb start=time() def test():         Conn = MySQLdb.connect(host="genome-mysql.cse.ucsc.edu",user='genome',db="hg18")         Cursor = Conn.cursor()