# If statement performance question

**URL:** https://discuss.elastic.co/t/if-statement-performance-question/333210
**Category:** Logstash
**Created:** [May 11, 2023, 12:43pm UTC](https://discuss.elastic.co/t/if-statement-performance-question/333210 "2023-05-11T12:43:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mgotechlock](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@mgotechlock](https://discuss.elastic.co/u/mgotechlock)
#### Post date: [May 11, 2023, 12:43pm UTC](https://discuss.elastic.co/t/if-statement-performance-question/333210/1 "2023-05-11T12:43:59Z")

</div>

Question  
If I use this IF statement,  
` if ("FTNTFGTpolicyname" in [message]) or ("FTNTFGTlogid" in [message]) {`, the CPU of the logstash server spikes to very high, pretty much forever.  
If I change it to this, CPU is minimal.  
`if ([message] =~ "FTNTFGTpolicyname") or ([message] =~ "FTNTFGTlogid") {`  
So, what's the difference? Would you expect this difference to make a large CPU difference?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 8, 2023, 12:44pm UTC](https://discuss.elastic.co/t/if-statement-performance-question/333210/2 "2023-06-08T12:44:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
