···2828 errorLog = log.New(os.Stderr, "", 0)
2929}
30303131-// timestamp returns current time in ISO 8601 format
3131+// timestamp returns current time with milliseconds (local time, no timezone)
3232func timestamp() string {
3333- return time.Now().Format(time.RFC3339)
3333+ return time.Now().Format("2006-01-02T15:04:05.000")
3434}
35353636func Verbose(format string, v ...interface{}) {
+1-1
internal/pds/scanner.go
···195195196196 // Save repos in batches (only tracks changes)
197197 if len(repoList) > 0 {
198198- batchSize := 10000
198198+ batchSize := 200000
199199200200 log.Verbose("Processing %d repos for %s (tracking changes only)", len(repoList), ep.Endpoint)
201201
+37-21
internal/storage/postgres.go
···741741742742func (p *PostgresDB) GetPDSDetail(ctx context.Context, endpoint string) (*PDSDetail, error) {
743743 query := `
744744- WITH target_endpoint AS (
744744+ WITH target_endpoint AS MATERIALIZED ( -- MATERIALIZED fence for optimization
745745 SELECT
746746 e.id,
747747 e.endpoint,
···752752 e.ip,
753753 e.ipv6
754754 FROM endpoints e
755755- WHERE e.endpoint = $1 AND e.endpoint_type = 'pds'
756756- ),
757757- aliases_agg AS (
758758- SELECT
759759- te.server_did,
760760- array_agg(e.endpoint ORDER BY e.discovered_at) FILTER (WHERE e.endpoint != te.endpoint) as aliases,
761761- MIN(e.discovered_at) as first_discovered_at
762762- FROM target_endpoint te
763763- LEFT JOIN endpoints e ON te.server_did = e.server_did
764764- AND e.endpoint_type = 'pds'
765765- AND te.server_did IS NOT NULL
766766- GROUP BY te.server_did
755755+ WHERE e.endpoint = $1
756756+ AND e.endpoint_type = 'pds'
757757+ LIMIT 1 -- Early termination since we expect exactly 1 row
767758 )
768759 SELECT
769760 te.id,
···783774 i.is_datacenter, i.is_vpn, i.is_crawler, i.is_tor, i.is_proxy,
784775 i.latitude, i.longitude,
785776 i.raw_data,
786786- COALESCE(aa.aliases, ARRAY[]::text[]) as aliases,
787787- aa.first_discovered_at
777777+ -- Inline aliases aggregation (avoid second CTE)
778778+ COALESCE(
779779+ ARRAY(
780780+ SELECT e2.endpoint
781781+ FROM endpoints e2
782782+ WHERE e2.server_did = te.server_did
783783+ AND e2.endpoint_type = 'pds'
784784+ AND e2.endpoint != te.endpoint
785785+ AND te.server_did IS NOT NULL
786786+ ORDER BY e2.discovered_at
787787+ ),
788788+ ARRAY[]::text[]
789789+ ) as aliases,
790790+ -- Inline first_discovered_at (avoid aggregation)
791791+ CASE
792792+ WHEN te.server_did IS NOT NULL THEN (
793793+ SELECT MIN(e3.discovered_at)
794794+ FROM endpoints e3
795795+ WHERE e3.server_did = te.server_did
796796+ AND e3.endpoint_type = 'pds'
797797+ )
798798+ ELSE NULL
799799+ END as first_discovered_at
788800 FROM target_endpoint te
789789- LEFT JOIN aliases_agg aa ON te.server_did = aa.server_did
790801 LEFT JOIN LATERAL (
791791- SELECT scan_data, response_time, version, scanned_at, user_count
792792- FROM endpoint_scans
793793- WHERE endpoint_id = te.id
794794- ORDER BY scanned_at DESC
802802+ SELECT
803803+ es.scan_data,
804804+ es.response_time,
805805+ es.version,
806806+ es.scanned_at,
807807+ es.user_count
808808+ FROM endpoint_scans es
809809+ WHERE es.endpoint_id = te.id
810810+ ORDER BY es.scanned_at DESC
795811 LIMIT 1
796812 ) latest ON true
797797- LEFT JOIN ip_infos i ON te.ip = i.ip
813813+ LEFT JOIN ip_infos i ON te.ip = i.ip;
798814 `
799815800816 detail := &PDSDetail{}