speeded up sql for contig set charts