add function inlining
This commit is contained in:
committed by
Steve Chavez
parent
d7907f4aa4
commit
946b113912
@@ -82,6 +82,11 @@ Leak-proof Abstraction
|
|||||||
|
|
||||||
There is no ORM involved. Creating new views happens in SQL with known performance implications. A database administrator can now create an API from scratch with no custom programming.
|
There is no ORM involved. Creating new views happens in SQL with known performance implications. A database administrator can now create an API from scratch with no custom programming.
|
||||||
|
|
||||||
|
Business Logic in Database Functions
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
There is nothing "business" about keeping data segregated across piles of layers. Use database functions to process data and get the performance benefits of data colocality and reduced network roundtrips.
|
||||||
|
|
||||||
One Thing Well
|
One Thing Well
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|||||||
@@ -340,6 +340,45 @@ A function that returns a table type can be filtered using the same filters as :
|
|||||||
|
|
||||||
curl "http://localhost:3000/rpc/best_films_2017?rating=gt.8&order=title.desc"
|
curl "http://localhost:3000/rpc/best_films_2017?rating=gt.8&order=title.desc"
|
||||||
|
|
||||||
|
.. _function_inlining:
|
||||||
|
|
||||||
|
Function Inlining
|
||||||
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
A function that follows the `rules for inlining <https://wiki.postgresql.org/wiki/Inlining_of_SQL_functions#Inlining_conditions_for_table_functions>`_ will also inline :ref:`filters <h_filter>`, :ref:`order <ordering>` and :ref:`limits <limits>`.
|
||||||
|
|
||||||
|
For example, for the following function:
|
||||||
|
|
||||||
|
.. code-block:: postgres
|
||||||
|
|
||||||
|
create function getallprojects() returns setof projects
|
||||||
|
language sql stable
|
||||||
|
as $$
|
||||||
|
select * from projects;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
Let's get its :ref:`explain_plan` when calling it with filters applied:
|
||||||
|
|
||||||
|
.. tabs::
|
||||||
|
|
||||||
|
.. code-tab:: http
|
||||||
|
|
||||||
|
GET /rpc/getallprojects?id=eq.1 HTTP/1.1
|
||||||
|
Accept: application/vnd.pgrst.plan
|
||||||
|
|
||||||
|
.. code-tab:: bash Curl
|
||||||
|
|
||||||
|
curl "http://localhost:3000/rpc/getallprojects?id=eq.1" \
|
||||||
|
-H "Accept: application/vnd.pgrst.plan"
|
||||||
|
|
||||||
|
.. code-block:: psql
|
||||||
|
|
||||||
|
Aggregate (cost=8.18..8.20 rows=1 width=112)
|
||||||
|
-> Index Scan using projects_pkey on projects (cost=0.15..8.17 rows=1 width=40)
|
||||||
|
Index Cond: (id = 1)
|
||||||
|
|
||||||
|
Notice there's no "Function Scan" node in the plan, which tells us it has been inlined.
|
||||||
|
|
||||||
.. _scalar_functions:
|
.. _scalar_functions:
|
||||||
|
|
||||||
Scalar functions
|
Scalar functions
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ Inserts
|
|||||||
|
|
||||||
- New :ref:`bulk_insert_default`.
|
- New :ref:`bulk_insert_default`.
|
||||||
|
|
||||||
|
Functions
|
||||||
|
~~~~~~~~~
|
||||||
|
|
||||||
|
- Filters on Table-Valued Functions are now guaranteed to be inlined. See :ref:`function_inlining`.
|
||||||
|
|
||||||
Horizontal Filtering
|
Horizontal Filtering
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ Cardano
|
|||||||
cd
|
cd
|
||||||
centric
|
centric
|
||||||
changelog
|
changelog
|
||||||
|
colocality
|
||||||
ClojureScript
|
ClojureScript
|
||||||
cloudfared
|
cloudfared
|
||||||
config
|
config
|
||||||
@@ -62,6 +63,8 @@ HTTP
|
|||||||
HTTPS
|
HTTPS
|
||||||
HV
|
HV
|
||||||
Ibarluzea
|
Ibarluzea
|
||||||
|
Inlining
|
||||||
|
inlined
|
||||||
Integrations
|
Integrations
|
||||||
ilike
|
ilike
|
||||||
imatch
|
imatch
|
||||||
@@ -147,6 +150,7 @@ refactor
|
|||||||
Reloadable
|
Reloadable
|
||||||
Remo
|
Remo
|
||||||
requester's
|
requester's
|
||||||
|
roundtrips
|
||||||
RESTful
|
RESTful
|
||||||
RestSharp
|
RestSharp
|
||||||
RLS
|
RLS
|
||||||
|
|||||||
Reference in New Issue
Block a user