Installing Analytics Accelerator
================================

To use the Postgres Analytics Accelerator (PGAA), you must install the
extension on your Postgres instance and enable the background worker for
the query engine. See :ref:`Analytics Accelerator compatibility <Analytics Accelerator compatibility>`  for a full list of supported
platforms.

Downloading and installing the package
--------------------------------------

Download the package from the EDB repository:

.. code:: shell

   export EDB_SUBSCRIPTION_TOKEN=<your-token>
   export EDB_SUBSCRIPTION_PLAN=<your-subscription-plan>
   curl -1sSLf "https://downloads.enterprisedb.com/$EDB_SUBSCRIPTION_TOKEN/$EDB_SUBSCRIPTION_PLAN/setup.deb.sh" | sudo -E bash
   sudo apt-get install -y <postgresql-distribution>-pgaa

.. code:: shell

   export EDB_SUBSCRIPTION_TOKEN=<your-token>
   EDB_SUBSCRIPTION_PLAN=<your-subscription-plan>
   curl -1sSLf "https://downloads.enterprisedb.com/$EDB_SUBSCRIPTION_TOKEN/$EDB_SUBSCRIPTION_PLAN/setup.rpm.sh" | sudo -E bash
   sudo dnf install -y <postgresql-distribution>-pgaa

Where

- ``$EDB_SUBSCRIPTION_TOKEN`` is the token you received when you
  registered for the EDB subscription.

- ``$EDB_SUBSCRIPTION_PLAN`` is either ``standard`` (for PGE or
  Community Postgres) or ``enterprise`` (for EPAS).

- ``<postgresql-distribution>`` specifies your Postgres distribution
  (``edb-postgresextended`` , ``edb-as`` , or ``postgres`` ), and
  version.

Enabling the extension
----------------------

To initialize PGAA, you must update your ``postgresql.conf`` file.
Adding ``pgaa`` to ``shared_preload_libraries`` allows Postgres to
manage the life cycle of the Seafowl query engine as a background
worker.

1. Edit ``postgresql.conf`` :

.. code:: ini

       shared_preload_libraries = pgaa
       pgaa.autostart_seafowl = on

1. Restart your Postgres service to load the new library.

2. Log in to your Postgres instance. Depending on whether this is a new
   installation or an update, run the appropriate command:

   - For new installations:

.. code:: sql

           CREATE EXTENSION IF NOT EXISTS pgaa CASCADE;

Using ``CASCADE`` ensures that required dependencies, such as the
Postgres File System (``PGFS`` ), are automatically installed.

::

   - For upgrading an existing installation: 

.. code:: sql

           ALTER EXTENSION pgaa UPDATE;

Verifying the installation
--------------------------

Confirm that the extension is active using the ``\dx`` meta-command or
by calling the version function:

.. code:: sql

   SELECT pgaa.pgaa_version();

Once installed, you can :ref:`Configuring storage locations <Configuring storage locations>`  to grant PGAA access to your data
lake, or integrate Postgres :ref:`Integrating with Iceberg catalogs <Integrating with Iceberg catalogs>`  .

Examples:

Point to parquet files:

.. code:: sql

   SELECT pgaa.test_storage_location (my-storage-location, false);

The function returns ``NULL`` if successful.
