Difference between revisions of "Useful SQL Queries"

From truxwiki.com
Jump to navigation Jump to search
Line 1: Line 1:
 
The following SQL queries were found to be useful when developing/debugging Truxton.
 
The following SQL queries were found to be useful when developing/debugging Truxton.
  
 +
=Database Server Information=
 +
==Number of Connections==
 +
<source lang="sql">
 +
SELECT COUNT(DISTINCT(numbackends)) FROM pg_stat_database
 +
</source>
 +
 +
==Maximum Number of Connections==
 +
Run this query as an administrator.
 +
<source lang="sql">
 +
SHOW max_connections
 +
</source>
 +
 +
==All Connection Information==
 +
<source lang="sql">
 +
SELECT * FROM
 +
(SELECT COUNT(*) "Current Number of Connections" FROM pg_stat_activity) q1,
 +
(SELECT setting::int "Reserved for Superuser" FROM pg_settings WHERE name=$$superuser_reserved_connections$$) q2,
 +
(SELECT setting::int "Maximum Number of Connections" FROM pg_settings WHERE name=$$max_connections$$) q3;
 +
</source>
 +
 +
==Current Activity==
 +
Ever wonder what the server is doing?
 +
<source lang="sql">
 +
SELECT
 +
state_change,
 +
age(localtimestamp, state_change),
 +
datname,
 +
application_name,
 +
state,
 +
query
 +
FROM pg_stat_activity
 +
ORDER BY
 +
state,
 +
age DESC,
 +
datname ASC
 +
</source>
 
=Files=
 
=Files=
 
Queries to get file lists.
 
Queries to get file lists.
Line 6: Line 42:
 
==Human Readable List==
 
==Human Readable List==
 
This will list files in a human readable format. The <code>WHERE</code> clause is commented out so you can add your own filter criteria.
 
This will list files in a human readable format. The <code>WHERE</code> clause is commented out so you can add your own filter criteria.
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
"File"."ID",
 
"File"."ID",
Line 36: Line 72:
 
--WHERE "File"."Signature" = -623191334
 
--WHERE "File"."Signature" = -623191334
 
ORDER BY "File"."ID"
 
ORDER BY "File"."ID"
</syntaxhighlight>
+
</source>
  
 
==Files with Depot Locations==
 
==Files with Depot Locations==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT "File"."ID",
 
SELECT "File"."ID",
 
"File"."ParentFileID",
 
"File"."ParentFileID",
Line 58: Line 94:
 
  AND "Content"."DepotID" = "Depot"."ID"
 
  AND "Content"."DepotID" = "Depot"."ID"
 
  AND "File"."FileTypeID" = "FileType"."ID"
 
  AND "File"."FileTypeID" = "FileType"."ID"
</syntaxhighlight>
+
</source>
  
 
==Files Truxton Can Exploit==
 
==Files Truxton Can Exploit==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
"ShortName",
 
"ShortName",
Line 73: Line 109:
 
)
 
)
 
ORDER BY "ShortName"
 
ORDER BY "ShortName"
</syntaxhighlight>
+
</source>
  
 
This one produces a single line of output that is easier for a human to read"
 
This one produces a single line of output that is easier for a human to read"
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT CONCAT( "ShortName", ' - ', "LongName")
 
SELECT CONCAT( "ShortName", ' - ', "LongName")
 
FROM "FileType"
 
FROM "FileType"
Line 86: Line 122:
 
)
 
)
 
ORDER BY "ShortName"
 
ORDER BY "ShortName"
</syntaxhighlight>
+
</source>
 
'''NOTE''' the <code>pfe</code> item is a bug. There should NOT be spaces in that name.
 
'''NOTE''' the <code>pfe</code> item is a bug. There should NOT be spaces in that name.
  
 
=Logs=
 
=Logs=
 
==All Messages==
 
==All Messages==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
"Log"."MediaID",
 
"Log"."MediaID",
Line 120: Line 156:
 
"Log"."MediaID",
 
"Log"."MediaID",
 
"Log"."When"
 
"Log"."When"
</syntaxhighlight>
+
</source>
  
 
==Only Error and Warnings==
 
==Only Error and Warnings==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
"Log"."MediaID",
 
"Log"."MediaID",
Line 153: Line 189:
 
"Log"."MediaID",
 
"Log"."MediaID",
 
"Log"."When"
 
"Log"."When"
</syntaxhighlight>
+
</source>
  
 
=Depots=
 
=Depots=
 
These queries will tell you if you're missing depot file entries.
 
These queries will tell you if you're missing depot file entries.
 
==Missing Content Depots==
 
==Missing Content Depots==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT DISTINCT( "DepotID" )
 
SELECT DISTINCT( "DepotID" )
 
FROM "Content"
 
FROM "Content"
Line 165: Line 201:
 
  AND "DepotID" NOT IN ( SELECT "ID" FROM "Depot" )
 
  AND "DepotID" NOT IN ( SELECT "ID" FROM "Depot" )
 
ORDER BY "DepotID"
 
ORDER BY "DepotID"
</syntaxhighlight>
+
</source>
  
 
==Missing Image Depots==
 
==Missing Image Depots==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT DISTINCT( "DepotID" )
 
SELECT DISTINCT( "DepotID" )
 
FROM "Image"
 
FROM "Image"
Line 178: Line 214:
 
  )
 
  )
 
ORDER BY "DepotID"
 
ORDER BY "DepotID"
</syntaxhighlight>
+
</source>
  
 
==Depot IDs in Use==
 
==Depot IDs in Use==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT DISTINCT "DepotID" AS "ID" FROM
 
SELECT DISTINCT "DepotID" AS "ID" FROM
 
(
 
(
Line 194: Line 230:
 
   SELECT "ThumbnailDepotID" AS "DepotID" FROM "ReviewItem"
 
   SELECT "ThumbnailDepotID" AS "DepotID" FROM "ReviewItem"
 
) AS "SubSelect"
 
) AS "SubSelect"
</syntaxhighlight>
+
</source>
  
 
==Depot IDs Not in Use==
 
==Depot IDs Not in Use==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT "ID"
 
SELECT "ID"
 
FROM "Depot"
 
FROM "Depot"
Line 215: Line 251:
 
  ) AS "SubSelect"
 
  ) AS "SubSelect"
 
)
 
)
</syntaxhighlight>
+
</source>
  
 
==URI in Filename Column==
 
==URI in Filename Column==
 
To detect when an ETL has put bad data into the <code>[Depot]</code> table.
 
To detect when an ETL has put bad data into the <code>[Depot]</code> table.
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT "ID", "Filename", "URI", "DepotTypeID", "MaximumSize", "Size", "IsLongTerm", "CryptoKey", "DepotStatusID"
 
SELECT "ID", "Filename", "URI", "DepotTypeID", "MaximumSize", "Size", "IsLongTerm", "CryptoKey", "DepotStatusID"
 
FROM "Depot"
 
FROM "Depot"
 
where "Filename" like '\\%'
 
where "Filename" like '\\%'
</syntaxhighlight>
+
</source>
  
 
==Change Depot URI==
 
==Change Depot URI==
 
When you move depots to a new share, the database needs to be fixed up.
 
When you move depots to a new share, the database needs to be fixed up.
 
This sample is what you would run if you need to change the machine name <code>SOFS-01</code> to a fully qualified [https://en.wikipedia.org/wiki/Domain_Name_System DNS] name.
 
This sample is what you would run if you need to change the machine name <code>SOFS-01</code> to a fully qualified [https://en.wikipedia.org/wiki/Domain_Name_System DNS] name.
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
UPDATE "Depot"
 
UPDATE "Depot"
 
SET "URI" = REPLACE( "URI", '\\SOFS-01\', '\\sofs-01.truxton.lab\Depot\')
 
SET "URI" = REPLACE( "URI", '\\SOFS-01\', '\\sofs-01.truxton.lab\Depot\')
</syntaxhighlight>
+
</source>
  
 
==Change Depot Path==
 
==Change Depot Path==
 
If you move depots to a new folder, you must update the <code>[Filename]</code> column of the <code>[Depot]</code> table.
 
If you move depots to a new folder, you must update the <code>[Filename]</code> column of the <code>[Depot]</code> table.
 
This sample is what you would do if you moved the depot folder from <code>C:\TruxtonData</code> to <code>C:\Storage</code>
 
This sample is what you would do if you moved the depot folder from <code>C:\TruxtonData</code> to <code>C:\Storage</code>
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
UPDATE "Depot"
 
UPDATE "Depot"
 
SET "Filename" = REPLACE( "Filename", 'C:\Truxton Data\Depot\', 'C:\Storage\Depot\')
 
SET "Filename" = REPLACE( "Filename", 'C:\Truxton Data\Depot\', 'C:\Storage\Depot\')
</syntaxhighlight>
+
</source>
  
 
=File Type Counts=
 
=File Type Counts=
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
"FileTypeID",
 
"FileTypeID",
Line 253: Line 289:
 
"FileType"."ShortName"
 
"FileType"."ShortName"
 
ORDER BY "NumberOfThatType" DESC
 
ORDER BY "NumberOfThatType" DESC
</syntaxhighlight>
+
</source>
  
 
=Messages=
 
=Messages=
 
==Messages and Subjects==
 
==Messages and Subjects==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
"Message"."ID",
 
"Message"."ID",
Line 269: Line 305:
 
LEFT OUTER JOIN "MessageType" ON ("Message"."MessageTypeID" = "MessageType"."ID" )
 
LEFT OUTER JOIN "MessageType" ON ("Message"."MessageTypeID" = "MessageType"."ID" )
 
ORDER BY "Message"."Sent"
 
ORDER BY "Message"."Sent"
</syntaxhighlight>
+
</source>
  
 
==Find Messages that did not Parse==
 
==Find Messages that did not Parse==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
"File"."ID",
 
"File"."ID",
Line 290: Line 326:
 
   SELECT "FileID" FROM "Message
 
   SELECT "FileID" FROM "Message
 
  )
 
  )
</syntaxhighlight>
+
</source>
  
 
=SSID=
 
=SSID=
 
==SSID and Associated Passwords==
 
==SSID and Associated Passwords==
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
DISTINCT "A_ID" AS "PasswordEntityID",
 
DISTINCT "A_ID" AS "PasswordEntityID",
Line 313: Line 349:
 
)
 
)
 
ORDER BY "SSID"."Value"
 
ORDER BY "SSID"."Value"
</syntaxhighlight>
+
</source>
  
 
=Entity=
 
=Entity=
 
==Human Readable==
 
==Human Readable==
 
How to get the entities to reprocess a piece of media.
 
How to get the entities to reprocess a piece of media.
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT  
 
SELECT  
 
"Entity"."ID",
 
"Entity"."ID",
Line 337: Line 373:
 
INNER JOIN "ObjectType" ON ( "Entity"."ObjectTypeID" = "ObjectType"."ID" )
 
INNER JOIN "ObjectType" ON ( "Entity"."ObjectTypeID" = "ObjectType"."ID" )
 
WHERE "Entity"."MediaID" = '139db997-1f71-58d2-46ae-e052bb67a946'::uuid
 
WHERE "Entity"."MediaID" = '139db997-1f71-58d2-46ae-e052bb67a946'::uuid
</syntaxhighlight>
+
</source>
  
 
=Loads=
 
=Loads=
 
==How Long did the Loads Take==
 
==How Long did the Loads Take==
 
This query is useful only when you are loading a bunch of media for an investigation at the same time.
 
This query is useful only when you are loading a bunch of media for an investigation at the same time.
<syntaxhighlight lang="sql">
+
<source lang="sql">
 
SELECT
 
SELECT
 
MIN("Start"),
 
MIN("Start"),
Line 353: Line 389:
 
   SELECT "MediaID" FROM "InvestigationMedia" WHERE "InvestigationID" = '20171021-0000-1111-2222-333333333333'::uuid
 
   SELECT "MediaID" FROM "InvestigationMedia" WHERE "InvestigationID" = '20171021-0000-1111-2222-333333333333'::uuid
 
  )
 
  )
</syntaxhighlight>
+
</source>
 
 
=Database Connections=
 
==Number of Connections==
 
<syntaxhighlight lang="sql">
 
SELECT COUNT(DISTINCT(numbackends)) FROM pg_stat_database
 
</syntaxhighlight>
 
 
 
==Maximum Number of Connections==
 
Run this query as an administrator.
 
<syntaxhighlight lang="sql">
 
SHOW max_connections
 
</syntaxhighlight>
 
 
 
==All Connection Information==
 
<syntaxhighlight lang="sql">
 
SELECT * FROM
 
(SELECT COUNT(*) "Current Number of Connections" FROM pg_stat_activity) q1,
 
(SELECT setting::int "Reserved for Superuser" FROM pg_settings WHERE name=$$superuser_reserved_connections$$) q2,
 
(SELECT setting::int "Maximum Number of Connections" FROM pg_settings WHERE name=$$max_connections$$) q3;
 
</syntaxhighlight>
 
  
 
=Links=
 
=Links=

Revision as of 09:53, 28 October 2020

The following SQL queries were found to be useful when developing/debugging Truxton.

Database Server Information

Number of Connections

SELECT COUNT(DISTINCT(numbackends)) FROM pg_stat_database

Maximum Number of Connections

Run this query as an administrator.

SHOW max_connections

All Connection Information

SELECT * FROM
(SELECT COUNT(*) "Current Number of Connections" FROM pg_stat_activity) q1,
(SELECT setting::int "Reserved for Superuser" FROM pg_settings WHERE name=$$superuser_reserved_connections$$) q2,
(SELECT setting::int "Maximum Number of Connections" FROM pg_settings WHERE name=$$max_connections$$) q3;

Current Activity

Ever wonder what the server is doing?

SELECT
state_change,
age(localtimestamp, state_change),
datname,
application_name,
state,
query
FROM pg_stat_activity 
ORDER BY
state,
age DESC,
datname ASC

Files

Queries to get file lists.

Human Readable List

This will list files in a human readable format. The WHERE clause is commented out so you can add your own filter criteria.

SELECT
"File"."ID",
"File"."MediaID",
"File"."ParentFileID",
"Origin"."Name" AS "Origin",
"FileType"."ShortName" AS "FileType",
"FN2"."Name",
"File"."OSLength",
"File"."HashID",
"File"."RawEntropy" * 0.00024414502395702993865779595324564 AS "Entropy",
"Filename"."Name" AS "Path",
"File"."FullPathID",
"File"."FileTypeID",
to_hex( "File"."Signature" ) AS "Signature",
to_hex( "File"."PhysicalDiskOffset" ) AS "DiskOffset",
"FileType"."LongName" AS "FileTypeDescription",
"File"."Created",
"File"."LastWrite",
"ContentStatus"."Name" AS "CStatus",
"File"."NumberOfChildren",
"File"."FilenameID"
FROM "File"
LEFT OUTER JOIN "FileType" ON ( "File"."FileTypeID" = "FileType"."ID" )
LEFT OUTER JOIN "Filename" AS "FN2" ON ( "File"."FilenameID" = "FN2"."ID" )
LEFT OUTER JOIN "Filename" ON ( "File"."FullPathID" = "Filename"."ID" )
LEFT OUTER JOIN "Origin" ON ( "File"."OriginID" = "Origin"."ID" )
LEFT OUTER JOIN "ContentStatus" ON ( "File"."ContentStatusID" = "ContentStatus"."ID" )
--WHERE "File"."Signature" = -623191334
ORDER BY "File"."ID"

Files with Depot Locations

SELECT "File"."ID",
"File"."ParentFileID",
"File"."FileTypeID",
"FileType"."ShortName",
"Filename"."Name",
"Content"."Offset",
"Content"."Length",
"Depot"."Filename"
FROM
"File", 
"Depot",
"Filename",
"Content",
"FileType"
WHERE "File"."HashID" = "Content"."Hash" 
 AND "File"."FilenameID" = "Filename"."ID"
 AND "Content"."DepotID" = "Depot"."ID"
 AND "File"."FileTypeID" = "FileType"."ID"

Files Truxton Can Exploit

SELECT
"ShortName",
"LongName"
FROM "FileType"
WHERE "ID" IN
(
  SELECT DISTINCT("FileTypeID")
  FROM "ETLRoute"
  WHERE "ETLQueueName" IN ('expand', 'email', 'remoteexpand', 'archives', 'pfe                             ')
)
ORDER BY "ShortName"

This one produces a single line of output that is easier for a human to read"

SELECT CONCAT( "ShortName", ' - ', "LongName")
FROM "FileType"
WHERE "ID" IN
(
  SELECT DISTINCT("FileTypeID")
  FROM "ETLRoute"
  WHERE "ETLQueueName" IN ('expand', 'email', 'remoteexpand', 'archives', 'pfe                             ')
)
ORDER BY "ShortName"

NOTE the pfe item is a bug. There should NOT be spaces in that name.

Logs

All Messages

SELECT
"Log"."MediaID",
"Log"."When",
"T"."String" AS "Type",
"S"."String" AS "Source",
"Log"."ProcessID",
"Log"."ThreadID",
"C"."String" AS "Client",
"U"."String" AS "User",
"M"."String" AS "Message"
FROM
"Log",
"LogString" AS "S",
"LogString" AS "C",
"LogString" AS "U",
"LogString" AS "M",
"LogString" AS "T"
WHERE
"Log"."LogStringSourceID" = "S"."ID" 
 AND "Log"."LogStringClientID" = "C"."ID" 
 AND "Log"."LogStringUserID" = "U"."ID" 
 AND "Log"."LogStringMessageID" = "M"."ID" 
 AND "Log"."LogStringTypeID" = "T"."ID"
-- AND "Log"."LogStringTypeID" <> 2 -- Don't show Info messages
-- AND "Log"."MediaID" = '11111111-1111-1111-1111-000000000001'::uuid
ORDER BY
"Log"."MediaID",
"Log"."When"

Only Error and Warnings

SELECT
"Log"."MediaID",
"Log"."When",
"Log"."LogStringTypeID",
"T"."String" AS "Type",
"S"."String" AS "Source",
"Log"."ProcessID",
"Log"."ThreadID",
"C"."String" AS "Client",
"U"."String" AS "User",
"M"."String" AS "Message"
FROM
"Log",
"LogString" AS "S",
"LogString" AS "C",
"LogString" AS "U",
"LogString" AS "M",
"LogString" AS "T"
WHERE
"Log"."LogStringSourceID" = "S"."ID" 
 AND "Log"."LogStringClientID" = "C"."ID" 
 AND "Log"."LogStringUserID" = "U"."ID" 
 AND "Log"."LogStringMessageID" = "M"."ID" 
 AND "Log"."LogStringTypeID" = "T"."ID"
 AND "Log"."LogStringTypeID" IN ( 0, 1 ) -- Don't show Info messages
-- AND "Log"."MediaID" = '11111111-1111-1111-1111-000000000001'::uuid
ORDER BY
"Log"."MediaID",
"Log"."When"

Depots

These queries will tell you if you're missing depot file entries.

Missing Content Depots

SELECT DISTINCT( "DepotID" )
FROM "Content"
WHERE
"DepotID" <> '00000000-0000-0000-0000-000000000000'::uuid
 AND "DepotID" NOT IN ( SELECT "ID" FROM "Depot" )
ORDER BY "DepotID"

Missing Image Depots

SELECT DISTINCT( "DepotID" )
FROM "Image"
WHERE 
"DepotID" <> '00000000-0000-0000-0000-000000000000'::uuid
 AND "DepotID" NOT IN
 (
   SELECT "ID" FROM "Depot"
 )
ORDER BY "DepotID"

Depot IDs in Use

SELECT DISTINCT "DepotID" AS "ID" FROM
(
  SELECT "DepotID" FROM "Content"
  UNION
  SELECT "DepotID" FROM "Free"
  UNION
  SELECT "DepotID" FROM "Image"
  UNION
  SELECT "DepotID" FROM "Slack"
  UNION
  SELECT "ThumbnailDepotID" AS "DepotID" FROM "ReviewItem"
) AS "SubSelect"

Depot IDs Not in Use

SELECT "ID"
FROM "Depot"
WHERE "ID" NOT IN
(
 SELECT DISTINCT "DepotID" AS "ID" FROM
 (
  SELECT "DepotID" FROM "Content"
  UNION
  SELECT "DepotID" FROM "Free"
  UNION
  SELECT "DepotID" FROM "Image"
  UNION
  SELECT "DepotID" FROM "Slack"
  UNION
  SELECT "ThumbnailDepotID" AS "DepotID" FROM "ReviewItem"
 ) AS "SubSelect"
)

URI in Filename Column

To detect when an ETL has put bad data into the [Depot] table.

SELECT "ID", "Filename", "URI", "DepotTypeID", "MaximumSize", "Size", "IsLongTerm", "CryptoKey", "DepotStatusID"
FROM "Depot"
where "Filename" like '\\%'

Change Depot URI

When you move depots to a new share, the database needs to be fixed up. This sample is what you would run if you need to change the machine name SOFS-01 to a fully qualified DNS name.

UPDATE "Depot"
SET "URI" = REPLACE( "URI", '\\SOFS-01\', '\\sofs-01.truxton.lab\Depot\')

Change Depot Path

If you move depots to a new folder, you must update the [Filename] column of the [Depot] table. This sample is what you would do if you moved the depot folder from C:\TruxtonData to C:\Storage

UPDATE "Depot"
SET "Filename" = REPLACE( "Filename", 'C:\Truxton Data\Depot\', 'C:\Storage\Depot\')

File Type Counts

SELECT
"FileTypeID",
"FileType"."ShortName",
COUNT( "FileTypeID" ) AS "NumberOfThatType"
FROM "File"
INNER JOIN "FileType" ON ( "FileType"."ID" = "File"."FileTypeID" )
GROUP BY
"FileTypeID",
"FileType"."ShortName"
ORDER BY "NumberOfThatType" DESC

Messages

Messages and Subjects

SELECT
"Message"."ID",
"MessageType"."ShortName" AS "Type",
"Sent", "Received", 
"MessageSubject"."Text" AS "Subject",
"NumberOfBodies",
"NumberOfAttachments"
FROM "Message"
LEFT OUTER JOIN "MessageSubject" ON ( "Message"."MessageSubjectID" = "MessageSubject"."ID" )
LEFT OUTER JOIN "MessageType" ON ("Message"."MessageTypeID" = "MessageType"."ID" )
ORDER BY "Message"."Sent"

Find Messages that did not Parse

SELECT
"File"."ID",
"FN2"."Name",
"File"."OSLength",
"File"."HashID",
"ContentStatus"."Name" AS "CStatus",
"File"."NumberOfChildren"
FROM "File"
LEFT OUTER JOIN "Filename" AS "FN2" ON ( "File"."FilenameID" = "FN2"."ID" )
LEFT OUTER JOIN "Origin" ON ( "File"."OriginID" = "Origin"."ID" )
LEFT OUTER JOIN "ContentStatus" ON ( "File"."ContentStatusID" = "ContentStatus"."ID" )
WHERE
"File"."FileTypeID" = 199
 AND "File"."ID" NOT IN
 (
   SELECT "FileID" FROM "Message
 )

SSID

SSID and Associated Passwords

SELECT
DISTINCT "A_ID" AS "PasswordEntityID",
"B_ID" AS "SSIDEntityID",
"SSID"."Value" AS "SSID",
"Password"."Value" AS "Password"
FROM "Relation"
INNER JOIN "Entity" AS "PasswordEntity" ON ( "Relation"."A_ID" = "PasswordEntity"."ID" )
INNER JOIN "Entity" AS "SSIDEntity" ON ( "Relation"."B_ID" = "SSIDEntity"."ID" )
INNER JOIN "EntityString" AS "Password" ON ("PasswordEntity"."EntityStringID" = "Password"."ID")
INNER JOIN "EntityString" AS "SSID" ON ("SSIDEntity"."EntityStringID" = "SSID"."ID")
WHERE "B_ID" IN 
(
  SELECT "ID" FROM "Entity"
  WHERE
   "MediaID" = '0e8beeee-1c42-91c3-e0b1-93edf6ed2d73'::uuid
   AND "EntityTypeID" = 25
)
ORDER BY "SSID"."Value"

Entity

Human Readable

How to get the entities to reprocess a piece of media.

SELECT 
"Entity"."ID",
"Entity"."FileID", 
"Entity"."EntityTypeID", 
"Entity"."EntityStringID",
"Entity"."Offset",
"Entity"."ObjectID", 
"Entity"."ObjectTypeID",
"Entity"."Length",
"Entity"."DataTypeID",
"ObjectType"."Name", 
"EntityString"."Value", 
"EntityType"."LongName"
FROM "Entity"
INNER JOIN "EntityType" ON ( "Entity"."EntityTypeID" = "EntityType"."ID" )
INNER JOIN "EntityString" ON ( "Entity"."EntityStringID" = "EntityString"."ID" )
INNER JOIN "ObjectType" ON ( "Entity"."ObjectTypeID" = "ObjectType"."ID" )
WHERE "Entity"."MediaID" = '139db997-1f71-58d2-46ae-e052bb67a946'::uuid

Loads

How Long did the Loads Take

This query is useful only when you are loading a bunch of media for an investigation at the same time.

SELECT
MIN("Start"),
MAX("End")
FROM "Event"
WHERE 
 "EventTypeID" = 1002
 AND "MediaID" IN
 (
   SELECT "MediaID" FROM "InvestigationMedia" WHERE "InvestigationID" = '20171021-0000-1111-2222-333333333333'::uuid
 )

Links

The following links have proven useful: