compiles queryP