2

I am connecting MATLAB to the Wharton Research Data Services COMPUSTAT database and am running a simple query

WRDS_Connect

setdbprefs('FetchInBatches','yes')
query = exec(WRDS, ['select gvkey from COMP.FUNDA where fyear = 2000 order by gvkey asc']);
result = fetch(query);
result.data

WRDS_Connect simply establishes a connection to WRDS server using JDBC drivers and

WRDS = database(instance, username, password, serverAddress);

The query is not too big and gives me 27000 rows of data. However it takes too long. Profiling shows that it takes about 5 minutes for these 27000 rows. I want to actually make more extensive queries but it should not take so long.

Is there anything I can do to speed things up? I've attached a screenshot of the profiling. Profiling Screenshot

Thanks for your help!

FlipperPA
  • 13,607
  • 4
  • 39
  • 71
rajomato
  • 1,167
  • 2
  • 10
  • 25

1 Answers1

0

If you have a PhD acount or above you can change approach a little bit.

I developed an API that lets you download datasets from WRDS unix servers. It's easy to use and faster.

Check it out on https://github.com/okomarov/wrds and let me know if you have problems.

wrds_install
w = wrds('username');
w.sas2csv('COMP.FUNDA');

The data will be saved in .\data\COMP.FUNDA.zip.

You can then:

  1. unzip the table
  2. import it with readtable()
  3. apply selction/filters in Matlab
Oleg
  • 10,406
  • 3
  • 29
  • 57
  • Hello, @Oleg, I want to use your package shown in the link to connect to wrds in matlab, but everytime I run wrds_install; and w = wrds('username','password'), my matlab (2015Ra) in laptop collapes immediately. I do not know the reason. – Shine Mar 01 '16 at 13:48
  • @Shine Can you please submit an issue on github giving as many details as possible to rerproduce the issue (OS, code example, if you get something printed in the command window before the crash, the crash report by the OS)? – Oleg Mar 01 '16 at 13:58