# Performance: composite term access vs. fact base access

**URL:** <https://swi-prolog.discourse.group/t/performance-composite-term-access-vs-fact-base-access/1744>\
**Category:** Help!\
**Created:** [January 14, 2020, 9:54am UTC](https://swi-prolog.discourse.group/t/performance-composite-term-access-vs-fact-base-access/1744 "2020-01-14T09:54:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [January 14, 2020, 9:54am UTC](https://swi-prolog.discourse.group/t/performance-composite-term-access-vs-fact-base-access/1744/1 "2020-01-14T09:54:48Z")

</div>

Hello,

I have some simple configuration data that is stored in the Prolog fact base.

There is a goal / process (say, hpg/1) that i am fine tuning for high performance. Currently, hpg/1 retrieves configuration data in its body through a fact access, e.g. config\_a(A).

The same high performance goal also has some global configuration data passed as argument, in form of a tuple with “accessor goals”: such as:

get\_a(Configuration, A), with Configuration bound to a structure such config(\_A, \_B, \_C) and get\_a(config(A, \_, \_, \_), A).

Configuration is passed as a “context” argument to the high performance goal hpg(Context).

I am curious which kind of access if faster:

config\_a(A) – that is a hash lookup

or get\_a(Context) – that is a structure binding lookup – which would require fact lookup only once before the high performance goal is performed.

I am counting “cycles” 🙂

any thoughts are much appreciated,

Dan
