# VIEW speed? TPS using a Filter on Primary Key

**URL:** <https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427>\
**Category:** questions\
**Tags:** topspeed, tps\
**Created:** [July 28, 2025, 12:29pm UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427 "2025-07-28T12:29:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan\_rademan](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/ea666f/32.png) [@johan\_rademan](https://clarionhub.com/u/johan_rademan)\
**Post date:** [July 28, 2025, 12:29pm UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427/1 "2025-07-28T12:29:17Z")

</div>

Hi,

Trying to solve some speed issues, using TPS

I enabled the driver trace to debug the following VIEW code  
The "next(ThisView)" generates a next in the driver trace for every record in the file.  
Using upper or not makes no difference.

What is missing with the view code here as the file has a primary key and the value is loaded in the filter.

thanks for any info

Johan

! code

```clarion
      open(thisview)
      ThisView{prop:filter} = 'UPPER(ITE:ITEM_ISN) = <39>' & Upper(ite:item_isn) & '<39>'
      set(ThisView)                                                 
      next(ThisView)                                                
      if error()
         ds_OutputDebugString('TVCweb testview error2=:' & error() & format(clock(),@t06))  
      end

! view decleration 

ThisView &View
View:item View(item)
                      Project(ite:item_isn)
                      Project(ite:item_desc)
                      Project(ite:item_amt)
                      Project(ite:item_qty)
                      Project(ite:item_gr_total)
                    END ! of ThisView

! file layout 
item FILE,DRIVER('TOPSPEED'),NAME(glo:item_f),PRE(ite),CREATE
item_isn_key KEY(ite:item_isn),PRIMARY
account_isn_key KEY(ite:account_isn,ite:invoice_isn,ite:item_date,ite:item_time),DUP,NOCASE
item_type_key KEY(ite:item_type,ite:item_date),DUP,NOCASE
order_isn_key KEY(ite:order_isn,ite:item_isn),NOCASE,OPT
cons_isn_key KEY(ite:cons_isn),DUP,NOCASE
item_desc_key KEY(ite:item_desc),DUP,NOCASE
invoice_isn_key KEY(ite:invoice_isn,ite:item_isn),DUP,NOCASE
piece_isn_key KEY(ite:piece_isn),DUP,NOCASE
acc_nr_key KEY(ite:acc_nr,ite:invoice_isn),DUP,NOCASE
print_key KEY(ite:invoice_isn,-ite:item_seq_nr,ite:item_desc),DUP,NOCASE
ordergrp_isn_key KEY(ite:ordergrp_isn),DUP,NOCASE
invoicing_key KEY(ite:invoice_isn,ite:account_isn,ite:item_grp_isn,-ite:item_DC,ite:item_date,ite:item_time),DUP,NOCASE !'D' comes before 'C' ----- see notes
integ_isn_key KEY(ite:integ_isn),DUP,NOCASE
stockper_isn_key KEY(ite:stockper_isn,ite:x_isn),DUP,NOCASE
gp_completed_key KEY(ite:gp_completed,ite:item_date),DUP,NOCASE
wlable_isn_key KEY(ite:item_type,ite:wlable_isn,ite:wtype_isn),DUP,NOCASE
stock_eff_key KEY(ite:item_type,ite:wlable_isn,ite:wtype_isn,ite:bottle_size,ite:item_date),DUP,NOCASE
record RECORD
item_isn STRING(20)
item_date LONG
item_time LONG
and lots more fields............

```

................

---

<div class="post-metadata">

**Author:** ![RchdR](https://clarionhub.com/letter_avatar_proxy/v4/letter/r/d78d45/32.png) [@RchdR](https://clarionhub.com/u/RchdR)\
**Post date:** [July 28, 2025, 3:07pm UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427/2 "2025-07-28T15:07:24Z")

</div>

Are you fetching this data across a network or from the workstation hard drive?

The workstation hard drive (Slow spin disk or fast NVMe disk) and motherboard (bus design and plugin boards) and CPU (cache and available instruction sets) and RAM (DDR4 or DDR5) will all affect the speed the TPS view is built, as will the CPU Quantum setting in Windows (24H2 Energy Saver mode which requires no reboot unlike the registry setting which alters the Quantum seen in PowerCfg Powermode) and the workload (other running apps) and Antivirus (is it scanning the TPS file and sending to the Cloud).

Oh, and the number of records in the TPS file can be a factor. Lots of records or large TPS file sizes can slow things down a bit.

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [July 28, 2025, 9:31pm UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427/3 "2025-07-28T21:31:56Z")

</div>

You could try code like below that is what you find the Legacy templates generate:

```clarion
  ThisView{prop:filter} = 'UPPER(ITE:ITEM_ISN) = <39>' & Upper(ite:item_isn) & '<39>'
  Set(Ite:item_isn_key) ! Tell view the Order by Key
  open(thisview) 
      ! set(ThisView) moved up and use file                                           
  next(ThisView) 

```

Read the Help on View Set Filter etc

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [July 29, 2025, 2:06am UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427/4 "2025-07-29T02:06:42Z")

</div>

Johan, try sending the prop:filter to debugview immediately after setting it, just so upu can see if it looks ok.  
I could see an issue if the right-side contained a quote.

Also, make sure the record is BINDed. If it isnt, then the gilter would fail.

BIND(ite:record)

---

<div class="post-metadata">

**Author:** ![vitesse](https://clarionhub.com/user_avatar/clarionhub.com/vitesse/32/837_2.png) [@vitesse](https://clarionhub.com/u/vitesse)\
**Post date:** [July 29, 2025, 3:17am UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427/5 "2025-07-29T03:17:57Z")

</div>

> [@johan\_rademan](#):
>
> `item_isn_key KEY(ite:item_isn),PRIMARY`

if you add NOCASE to your primary key does it make a difference?

I am not sure how smart the query processor in the tps driver is but at the moment you have no key that can be used by the filter so it needs to read the whole file.

---

<div class="post-metadata">

**Author:** ![CarlBarnes](https://clarionhub.com/user_avatar/clarionhub.com/carlbarnes/32/1859_2.png) [@CarlBarnes](https://clarionhub.com/u/CarlBarnes)\
**Post date:** [July 29, 2025, 12:04pm UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427/6 "2025-07-29T12:04:59Z")

</div>

> [@vitesse](#):
>
> if you add NOCASE to your primary key does it make a difference

Good catch!

I would guess the ISN is all Numbers and special characters (no letters), if so first try removing the UPPER(). Change it to CLIP() so no explicit trailing spaces.

```clarion
  ThisView{prop:filter} = 'ITE:ITEM_ISN = <39>' & clip(ite:item_isn) & '<39>'
  Set(Ite:item_isn_key)

```

* * *

If you don’t need features of the VIEW this can be done with Set(key,key):

```clarion
CLEAR(ite:record,-1)
ITE:ITEM_ISN = desired_value
Set(Ite:item_isn_key,Ite:item_isn_key)                                           
next(item) 

```

But that’s a primary key so GET(File,Key) makes the most sense. But I’d guess you were testing the View.

---

<div class="post-metadata">

**Author:** ![Jim-Morgan](https://clarionhub.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@Jim-Morgan](https://clarionhub.com/u/Jim-Morgan)\
**Post date:** [August 2, 2025, 1:37pm UTC](https://clarionhub.com/t/view-speed-tps-using-a-filter-on-primary-key/8427/7 "2025-08-02T13:37:28Z")

</div>

Add ThisView{Prop:Buffer} = x (50?)
