### Custom & Foreign Scans
![[assets/ex_customscanforeignscan.png|256]]
### The Explain Trace
```sql
-- Conceptual plan for a Foreign Scan (e.g., file_fdw)
EXPLAIN SELECT * FROM external_logs;
```
```text
Foreign Scan on external_logs (cost=1.00..2.10 rows=10 width=32)
Foreign File: /var/lib/postgres/data/logs.csv
Foreign File Size: 1024
```
---
- **Description**: Scans foreign tables or data sources.
- **Performance**: Entirely dependent on the external source's latency and the efficiency of the Foreign Data Wrapper (FDW) or custom extension.
- **Factors**: Network latency (for remote DBs), disk I/O (for local files), and implementation-specific overhead.
- **Cost**: Defined by the FDW's custom cost model.
![[assets/ex_foreign_scan.svg|256]]
- **Operates on**: [[Structures/Result Set]]
- **Workloads**:
- [[Workloads/Client/Activity/ClientRead|Client: ClientRead]]
- [[Workloads/Client/Activity/ClientWrite|Client: ClientWrite]]
- [[Workloads/IO/DataFile/DataFileRead|IO: DataFileRead]]
- [[Workloads/LWLock/Buffers/BufferContent|LWLock: BufferContent]]