extract data directly from database for huge speedup