Large Search Results
Querying, Filtering, and Spliting Large Result Sets
The most robust way to export, search, query, and filter large data sets from GRAX is using Search Jobs
. Simply navigate to the Search
tab and choose New Search Job
and enter the criteria to find the data you are looking for. The data is prepared in a versatile CSV file that you can download or immediately restore back into Salesforce.
Search Jobs
Search Jobs
provide a robust bulk search capabilities, allowing you to find large sets of records that have been archived, deleted, or both.
Querying Large GRAX Search Results
The instructions below give you a framework to do complex queries, joins, filters, and segmentation of large Search Job
results. (In the below sample we are using a 564.8 MB file of Tasks containing 3,009,400 search results)
-
Download the SQLite open source tool.
-
Download the GRAX
Search Job
results via CSV save asgraxsearchresults.csv
to where you saved Step 1. -
Open a Terminal / command-line and navigate to where
SQLite
and thegraxsearchresults.csv
are downloaded. -
Execute the below statements in the Terminal / command-line to load the
graxsearchresults.csv
results into memory and temporary SQL table namedtempsearchtable
.- NOTE: Before proceeding, please ensure you have sufficient system resources to load the
graxsearchresults.csv
in
memory.
sqlite3 .import ./graxsearchresults.csv tempsearchtable --csv .mode box
- NOTE: Before proceeding, please ensure you have sufficient system resources to load the
-
Get count of
tempsearchtable
sqlite> select count(*) from tempsearchtable; ┌──────────┐ │ count(*) │ ├──────────┤ │ 3009400 │ └──────────┘
-
How to search by a Date field.
sqlite> select count(*) from tempsearchtable where datetime(CreatedDate)>'2022-9-30' and datetime(CreatedDate)<'2022-10-05T21:00:00'; ┌──────────┐ │ count(*) │ ├──────────┤ │ 1284400 │ └──────────┘
-
How to search by Boolean
sqlite> select count(*) from tempsearchtable where boolean(IsClosed)=true; ┌──────────┐ │ count(*) │ ├──────────┤ │ 2623005 │ └──────────┘
-
How to export search results to CSV file
sqlite> .mode csv sqlite> .header on sqlite> .once ./filteredresults.csv sqlite> select Id from tempsearchtable where datetime(CreatedDate)>'2022-9-30' and datetime(CreatedDate)<'2022-11-1';
$ head -10 ./filteredresults.csv Id 00T5500000RFpA8EAL 00T5500000RFq0nEAD 00T5500000RFrtXEAT 00T5500000RKAx0EAH 00T5500000RKCSIEA5 00T5500000RKHgMEAX 00T5500000RKJeVEAX 00T5500000RKUZFEA5 00T5500000RKbU8EAL 00T5500000RKcsLEAT
SQLite Help
The preceding steps use open source SQLite; you can find the SQLite Help Documentation Here
Updated about 2 months ago