<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start in Publishing and Managing Services Questions</title>
    <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1293741#M956</link>
    <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633136"&gt;@RoyJackson_AlertMedia&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That looks like a bug. As I said I was not able to repro this but mine was a very simple use case. I guess this bug must be very specific to your workflow. I'd strongly recommend you to reach out to Esri Support and have an analyst look at this and if needed they will log a bug.&lt;/P&gt;&lt;P&gt;On % sign in the name, long story short this is expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While you will be waiting on an analyst took at this, I'd like you to try this workaround. For that we will use &lt;STRONG&gt;discrete parameter&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/define-parameters-in-a-query-layer.htm#ESRI_SECTION1_DA513455E19946BBBC3053C6263054F3" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/define-parameters-in-a-query-layer.htm#ESRI_SECTION1_DA513455E19946BBBC3053C6263054F3&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the basic idea is to use a sql that won't return any records to define the query layer and at run time we will overwrite that parameter value to return results via map service export/query operation.&lt;/P&gt;&lt;P&gt;the sql will look like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;SELECT &amp;lt;.....&amp;gt; from aTable
WHERE 1 = ::aValue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then set the default value for this parameter 0&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TanuHoque_0-1685146792542.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/71849i51FEE938CAE03756/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TanuHoque_0-1685146792542.png" alt="TanuHoque_0-1685146792542.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;That makes the query to return no records. Therefore, in the next page of query layer creation dialog, you need to specify geometry type, srs etc. yourself.&lt;/P&gt;&lt;P&gt;once published, you need to update the value for this query parameter with 1 to make the where clause be like 1=1... and then you can add your other clauses with AND or OR operator...&lt;/P&gt;&lt;P&gt;In map service &lt;STRONG&gt;export&lt;/STRONG&gt; call you need to use &lt;STRONG&gt;&lt;SPAN class=""&gt;layerParameterValues&lt;/SPAN&gt;&lt;/STRONG&gt; parameter. &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/export-map.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/export-map.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;for &lt;STRONG&gt;query&lt;/STRONG&gt; operation use &lt;STRONG&gt;&lt;SPAN class=""&gt;parameterValues&lt;/SPAN&gt;&lt;/STRONG&gt; parameter. &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer-.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you use map viewer, you can set these values by using &lt;STRONG&gt;custom parameters&lt;/STRONG&gt; option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 27 May 2023 00:30:33 GMT</pubDate>
    <dc:creator>TanuHoque</dc:creator>
    <dc:date>2023-05-27T00:30:33Z</dc:date>
    <item>
      <title>Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1289863#M944</link>
      <description>&lt;P&gt;Esri Specs:&lt;/P&gt;&lt;P&gt;ArcGIS Server 11.1, ArcPro 3.1&lt;/P&gt;&lt;P&gt;PostGIS running on AWS Aurora.&amp;nbsp; Not a managed geodatabase.&amp;nbsp; DB views having tables, tables having geography columns, with some foreign data wrapper foreign tables joined, pointing to other systems for the per-user permissions content.&lt;/P&gt;&lt;P&gt;We have a unique relational data model, where the features in layers change based on the user viewing them.&amp;nbsp;&amp;nbsp; The primary layers are groups, users, and devices.&amp;nbsp; A group has users, a user has devices.&amp;nbsp; Data is segmented by customer_id.&lt;/P&gt;&lt;P&gt;There are 2 types of users - full administrators can see everything for their customer_id. Restricted administrators can only see certain records, based on dynamic/realtime membership in groups for their customer_id.&amp;nbsp;&lt;/P&gt;&lt;P&gt;No user can see data for all customer_ids.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have 2 sets of database views - for both sets of views, they are ONLY valid when a where clause restricts the data returned.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Full admin views - &lt;STRONG&gt;must&lt;/STRONG&gt; include filter where customer_id = 123&lt;/P&gt;&lt;P&gt;Restricted admin views - &lt;STRONG&gt;must&lt;/STRONG&gt; include filter where customer_id = 123 and admin_id = 456&lt;/P&gt;&lt;P&gt;If we were to query these views without a where clause, we are requesting an insane amount of data, beyond the capacity of the systems to deliver it.&amp;nbsp; When publishing services having query layers to these views, the service times out, and will not start up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each layer in the service definition, when the service starts esri is asking postgis - "select * from massiveview".&amp;nbsp; This is an impossible query to request for these views.&lt;/P&gt;&lt;P&gt;One workaround has been to have a view on top of a view - before publishing the service, we make a view&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;CREATE VIEW &lt;/SPAN&gt;vw_all_addresses_layer_v1 &lt;SPAN&gt;as&lt;BR /&gt;&lt;/SPAN&gt;(&lt;BR /&gt;    &lt;SPAN&gt;select &lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;description&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;from &lt;/SPAN&gt;all_addresses_layer&lt;BR /&gt;    &lt;SPAN&gt;where &lt;/SPAN&gt;&lt;SPAN&gt;customer_id &lt;/SPAN&gt;= &lt;SPAN&gt;123&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;and then after the service is published and started, we recreate the view to exclude the where clause&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;DROP VIEW IF EXISTS &lt;/SPAN&gt;vw_all_addresses_layer_v1&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;CREATE VIEW &lt;/SPAN&gt;vw_all_addresses_layer_v1 &lt;SPAN&gt;as&lt;BR /&gt;&lt;/SPAN&gt;(&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;select &lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;:&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;description&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;from &lt;/SPAN&gt;all_addresses_layer&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;By doing this, we are able to have the service start up, because the select * query is reasonable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;After publishing, if we query the service using the proper filters, the service responds quickly. &amp;nbsp; However, we cannot ever stop and start (or recycle) this service, because it would timeout, due to the massive amount of data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why are "select * from queryLayer" queries being executed?&lt;/P&gt;&lt;P&gt;How can we prevent these "select * from queryLayer" queries from being executed?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When are they executed during a service's lifecycle? (upon start, upload uploading service definition, upon recycling)?&amp;nbsp; When more instances spin up?&amp;nbsp; Just the first instance?&lt;/P&gt;&lt;P&gt;Is there data captured from these select * requests, and stored in a file somewhere, that we could pre-populate with content, so that the query is not executed during service start up?&amp;nbsp; Any count that is captured by a select * would not be valid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why do we see queries like this:&amp;nbsp; SELECT * FROM sde.sde_layers LIMIT 0&amp;nbsp;&amp;nbsp; when we are not using SDE?&amp;nbsp;&amp;nbsp; If we had this SDE table, would the "select *" queries still occur?&lt;/P&gt;&lt;P&gt;Last question - does ArcGIS server have a preference for using geometry or geography as the spatial data type?&amp;nbsp; We see requests like this for tables having geography data:&amp;nbsp; SELECT ST_GEOMETRYTYPE(pin::GEOMETRY), ST_SRID(pin) FROM public.vw_all_geoaddresses_layer_esri WHERE pin is not null limit 1;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you, this is a big bottleneck in our potential adoption of this technology.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2620"&gt;@TanuHoque&lt;/a&gt;&amp;nbsp; your named was mentioned on a call earlier as an SME on this topic.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 22:38:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1289863#M944</guid>
      <dc:creator>RoyJackson_AlertMedia</dc:creator>
      <dc:date>2023-05-16T22:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1289868#M945</link>
      <description>&lt;P&gt;I'm not going to pretend to be a DBA or answer things on that line.&amp;nbsp; But in days of old when we had issues like this, we'd publish the service with a minimum number of instances of 0 and a max of X.&amp;nbsp; Clearly before the days of shared services, so you would need dedicated instances now.&amp;nbsp; Once it's published, then you go into server manager and increase the min instances to the value you need.&lt;/P&gt;&lt;P&gt;It was a bit hacky, but got around DB issues.&amp;nbsp; Not promising it will work, but give it a try and see if you can at least publish the service?&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 22:53:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1289868#M945</guid>
      <dc:creator>Scott_Tansley</dc:creator>
      <dc:date>2023-05-16T22:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1290127#M946</link>
      <description>&lt;P&gt;Good idea.&lt;/P&gt;&lt;P&gt;That does allow the service to start, with 0 instances running.&amp;nbsp;&amp;nbsp; When I go to the service in the rest/services directory, the first instance starts up and we get the "select *" queries failing.&lt;/P&gt;&lt;DIV class=""&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DEBUG&lt;/TD&gt;&lt;TD&gt;May 17, 2023, 8:12:16 AM&lt;/TD&gt;&lt;TD&gt;Shutting down context for service: esriViews_v1.MapServer&lt;/TD&gt;&lt;TD&gt;Server&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SEVERE&lt;/TD&gt;&lt;TD&gt;May 17, 2023, 8:12:16 AM&lt;/TD&gt;&lt;TD&gt;Failed to construct instance of service 'esriViews_v1.MapServer'. Service startup timeout.&lt;/TD&gt;&lt;TD&gt;Server&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DEBUG&lt;/TD&gt;&lt;TD&gt;May 17, 2023, 8:07:38 AM&lt;/TD&gt;&lt;TD&gt;EndCursor;ExecuteQuery 7 ms;Database: ip-10-132-64-159.ec2.internal;SQL: SELECT * FROM maps_db.public.vw_all_geoaddresses_layer_v1;Number of rows returned: 0&lt;/TD&gt;&lt;TD&gt;esriViews_v1.MapServer&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DEBUG&lt;/TD&gt;&lt;TD&gt;May 17, 2023, 8:07:18 AM&lt;/TD&gt;&lt;TD&gt;GetAllDatasets.&lt;/TD&gt;&lt;TD&gt;esriViews_v1.MapServer&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 17 May 2023 15:13:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1290127#M946</guid>
      <dc:creator>RoyJackson_AlertMedia</dc:creator>
      <dc:date>2023-05-17T15:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1290446#M947</link>
      <description>&lt;P&gt;This is probably DBA territory.&amp;nbsp; I once saw something similar, and the DBA had to do an awful amount of tuning and optimisation to get the query to perform well enough for ArcGIS to use it.&amp;nbsp; Ultimately "in that situation" all of the issues were Database related and not ArcGIS Server.&amp;nbsp; Once the database was tuned, the server worked beautifully.&amp;nbsp; Sorry, I need to step away on that note.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 22:03:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1290446#M947</guid>
      <dc:creator>Scott_Tansley</dc:creator>
      <dc:date>2023-05-17T22:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1291903#M952</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633136"&gt;@RoyJackson_AlertMedia&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the delay. I just tried with a dataset that has about 65 million records. My query that used to define the query layer is a simple one i.e. "Select * from aTable".&lt;/P&gt;&lt;P&gt;And it works fine for me. Map service gets started without any delay or anything.&lt;/P&gt;&lt;P&gt;I have a question though:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;did you create the query layer in ArcGIS Pro? Or you created in ArcMap and imported that in Pro?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you pls do this for me?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;save your query layer as a Layer File (.lyrx)&lt;/LI&gt;&lt;LI&gt;open that in a text editor&lt;/LI&gt;&lt;LI&gt;check if the following properties are written in there and they are not empty&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TanuHoque_0-1684801945806.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/71360i283CBA66832FAEF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TanuHoque_0-1684801945806.png" alt="TanuHoque_0-1684801945806.png" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if they all look good and you are still running into the performance issue, I'd need you to reach out to Esri Support to help us reproduce this in house.&lt;/P&gt;&lt;P&gt;While we will investigating that, I think I might be able to give your a hack-y workaround &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; since you mentioned about adding the following where-clause give you a trick to work around the initial startup... and of course you can use that as you run into this issue every time map service recycles.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;where &lt;/SPAN&gt;&lt;SPAN&gt;customer_id &lt;/SPAN&gt;= &lt;SPAN&gt;123&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... of course whether the workaround will be acceptable in your situation will be a different question by itself. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 00:48:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1291903#M952</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2023-05-23T00:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1293529#M955</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp;&amp;nbsp; I do see those properties populated correctly.&amp;nbsp;&amp;nbsp; "spatialStorageType": 15&amp;nbsp; only difference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only weird thing I see, which I also noticed in server logs, is the dataConnection.dataset property has an incorrect "%" in there.&amp;nbsp;&amp;nbsp; "dataset": "maps_db.public.%vw_all_geoaddresses_layer_v1",&lt;/P&gt;&lt;P&gt;The "select * " forced us to change the data model quite a bit, removing some postgres foreign database dependencies which were causing the crash.&amp;nbsp; Not optimal.&amp;nbsp; Would be great if we could somehow not run this select * query for general stability reasons, that would make the overall architecture much cleaner.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 16:47:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1293529#M955</guid>
      <dc:creator>RoyJackson_AlertMedia</dc:creator>
      <dc:date>2023-05-26T16:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1293741#M956</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633136"&gt;@RoyJackson_AlertMedia&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That looks like a bug. As I said I was not able to repro this but mine was a very simple use case. I guess this bug must be very specific to your workflow. I'd strongly recommend you to reach out to Esri Support and have an analyst look at this and if needed they will log a bug.&lt;/P&gt;&lt;P&gt;On % sign in the name, long story short this is expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While you will be waiting on an analyst took at this, I'd like you to try this workaround. For that we will use &lt;STRONG&gt;discrete parameter&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/define-parameters-in-a-query-layer.htm#ESRI_SECTION1_DA513455E19946BBBC3053C6263054F3" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/define-parameters-in-a-query-layer.htm#ESRI_SECTION1_DA513455E19946BBBC3053C6263054F3&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the basic idea is to use a sql that won't return any records to define the query layer and at run time we will overwrite that parameter value to return results via map service export/query operation.&lt;/P&gt;&lt;P&gt;the sql will look like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;SELECT &amp;lt;.....&amp;gt; from aTable
WHERE 1 = ::aValue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then set the default value for this parameter 0&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TanuHoque_0-1685146792542.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/71849i51FEE938CAE03756/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TanuHoque_0-1685146792542.png" alt="TanuHoque_0-1685146792542.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;That makes the query to return no records. Therefore, in the next page of query layer creation dialog, you need to specify geometry type, srs etc. yourself.&lt;/P&gt;&lt;P&gt;once published, you need to update the value for this query parameter with 1 to make the where clause be like 1=1... and then you can add your other clauses with AND or OR operator...&lt;/P&gt;&lt;P&gt;In map service &lt;STRONG&gt;export&lt;/STRONG&gt; call you need to use &lt;STRONG&gt;&lt;SPAN class=""&gt;layerParameterValues&lt;/SPAN&gt;&lt;/STRONG&gt; parameter. &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/export-map.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/export-map.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;for &lt;STRONG&gt;query&lt;/STRONG&gt; operation use &lt;STRONG&gt;&lt;SPAN class=""&gt;parameterValues&lt;/SPAN&gt;&lt;/STRONG&gt; parameter. &lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer-.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you use map viewer, you can set these values by using &lt;STRONG&gt;custom parameters&lt;/STRONG&gt; option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 May 2023 00:30:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1293741#M956</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2023-05-27T00:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294565#M957</link>
      <description>&lt;P&gt;This is very intriguing, experimenting with it now.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possibly to configure these custom discrete parameters on querylayer using arcpy?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 16:31:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294565#M957</guid>
      <dc:creator>RoyJackson_AlertMedia</dc:creator>
      <dc:date>2023-05-31T16:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294574#M958</link>
      <description>&lt;P&gt;It looks like I can only specify the parameterValues / layerParameter values for MapService, not FeatureService.&amp;nbsp; Is that correct?&amp;nbsp;&amp;nbsp; (we need feature access in this example)&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 16:54:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294574#M958</guid>
      <dc:creator>RoyJackson_AlertMedia</dc:creator>
      <dc:date>2023-05-31T16:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294829#M960</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633136"&gt;@RoyJackson_AlertMedia&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes, that is correct.&lt;BR /&gt;that said, I thought you can't enable Feature Access with a database view is used as a source of a query layer.... &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/sharing/analyzer-error-messages/00294-editable-feature-services-cannot-contain-database-views.htm" target="_self"&gt;An analyzer error&lt;/A&gt; should block you from publishing such layer as an Enterprise by ref feature service.&lt;/P&gt;&lt;P&gt;So, you have some editing workflow with this type of layers?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 22:55:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294829#M960</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2023-05-31T22:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294831#M961</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633136"&gt;@RoyJackson_AlertMedia&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not 100% sure on that. Since we allow accessing the full CIM definition for a layer via arcpy, maybe we should be able to do something.&lt;/P&gt;&lt;P&gt;What is your workflow where you want to use arcpy?&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 22:58:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1294831#M961</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2023-05-31T22:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Starting a feature service with query layers results in select * from massiveview, crashing database and service doesn't start</title>
      <link>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1298354#M967</link>
      <description>&lt;P&gt;We are exposing customer-specific addresses, mobile devices on a map.&amp;nbsp; No user can ever see the whole database, which would result in giant fines for revealing personally identifiable information.&amp;nbsp; Depending on who you are in the customer, you also see different information.&lt;/P&gt;&lt;P&gt;We need to use feature service so that we can interact with these pins using the client-side geometry engine for geofencing, dynamic distance calculations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;An API server in between the web mapping client, and arcgis server, determines which features to display (either with a customer identifier scraped from oauth token, or a list of allowable ids calculated by db lookups / hitting another API).&amp;nbsp; So this API constructs the where clause to perform the appropriate filtering, and passes that to arcgis server.&lt;/P&gt;&lt;P&gt;The publishing workflow is - we need to publish these services programatically to a slew of environments (testing, staging, load testing, prod1 prod2 etc) via CI/CD.&amp;nbsp;&amp;nbsp; So anything we need to setup for a service, we can't really have someone clicking around in ArcPro.&amp;nbsp; Ideally we could create one service definition with pro, and deploy that to different arcgis servers, pointing the definition to different databases, via scripts running on the server instance (not arcpro due to headless processing being something custom to implement if I understand correctly)&lt;/P&gt;&lt;P&gt;I looked and played a bit at the CIM object in python, it didn't seem possible to make the configuration.&amp;nbsp; It barked that the programmatic changes relevant to this topic were not valid.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 22:02:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/publishing-and-managing-services-questions/starting-a-feature-service-with-query-layers/m-p/1298354#M967</guid>
      <dc:creator>RoyJackson_AlertMedia</dc:creator>
      <dc:date>2023-06-12T22:02:35Z</dc:date>
    </item>
  </channel>
</rss>

