Automatic Partitioning of Database Applications