Alternative to Scratch Folder to help with memory usage.
import arcpy
import os
import shutil
import tempfile
GDB_NAME = 'test.gdb'
#Create a file geodatabase.
workspace = tempfile.mkdtemp()
gdb_path = os.path.join(workspace, GDB_NAME)
arcpy.CreateFileGDB_management(workspace, GDB_NAME)
#Create a feature class, and add fields.
#Populate the feature class with features.
#Perform the test queries, and report the number of results.
#Clean up.
shutil.rmtree(workspace)